feat: data-driven.

This commit is contained in:
徐聪
2022-01-05 11:46:30 +08:00
parent 831be5c9c3
commit af8c60f7ab
+11 -8
View File
@@ -98,11 +98,21 @@ func (r *hrpRunner) Run(testcases ...ITestCase) error {
log.Error().Err(err).Msg("[Run] convert ITestCase interface to TestCase struct failed")
return err
}
cfg := testcase.Config.ToStruct()
for it := cfg.ParametersSetting.Iterators[0]; it.HasNext(); {
// iterate through all parameter iterators and update case variables
// iterate through all parameter iterators and update case variables
for _, it := range cfg.ParametersSetting.Iterators {
if it.HasNext() {
cfg.Variables = mergeVariables(it.Next(), cfg.Variables)
}
}
if err := r.newCaseRunner(testcase).run(); err != nil {
log.Error().Err(err).Msg("[Run] run testcase failed")
return err
}
}
}
return nil
}
@@ -143,13 +153,7 @@ func (r *caseRunner) run() error {
}
cfg := config.ToStruct()
log.Info().Str("testcase", config.Name()).Msg("run testcase start")
for it := cfg.ParametersSetting.Iterators[0]; it.HasNext(); {
// iterate through all parameter iterators and update case variables
for _, it = range cfg.ParametersSetting.Iterators {
if it.HasNext() {
cfg.Variables = mergeVariables(it.Next(), cfg.Variables)
}
}
r.startTime = time.Now()
for index := range r.TestCase.TestSteps {
_, err := r.runStep(index, cfg)
@@ -159,7 +163,6 @@ func (r *caseRunner) run() error {
}
}
}
}
log.Info().Str("testcase", config.Name()).Msg("run testcase end")
return nil