mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-09 22:44:05 +08:00
feat: data-driven.
This commit is contained in:
37
runner.go
37
runner.go
@@ -98,9 +98,19 @@ func (r *hrpRunner) Run(testcases ...ITestCase) error {
|
|||||||
log.Error().Err(err).Msg("[Run] convert ITestCase interface to TestCase struct failed")
|
log.Error().Err(err).Msg("[Run] convert ITestCase interface to TestCase struct failed")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := r.newCaseRunner(testcase).run(); err != nil {
|
cfg := testcase.Config.ToStruct()
|
||||||
log.Error().Err(err).Msg("[Run] run testcase failed")
|
for it := cfg.ParametersSetting.Iterators[0]; it.HasNext(); {
|
||||||
return err
|
// 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
|
return nil
|
||||||
@@ -143,20 +153,13 @@ func (r *caseRunner) run() error {
|
|||||||
}
|
}
|
||||||
cfg := config.ToStruct()
|
cfg := config.ToStruct()
|
||||||
log.Info().Str("testcase", config.Name()).Msg("run testcase start")
|
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
|
r.startTime = time.Now()
|
||||||
for _, it = range cfg.ParametersSetting.Iterators {
|
for index := range r.TestCase.TestSteps {
|
||||||
if it.HasNext() {
|
_, err := r.runStep(index, cfg)
|
||||||
cfg.Variables = mergeVariables(it.Next(), cfg.Variables)
|
if err != nil {
|
||||||
}
|
if r.hrpRunner.failfast {
|
||||||
}
|
return errors.Wrap(err, "abort running due to failfast setting")
|
||||||
r.startTime = time.Now()
|
|
||||||
for index := range r.TestCase.TestSteps {
|
|
||||||
_, err := r.runStep(index, cfg)
|
|
||||||
if err != nil {
|
|
||||||
if r.hrpRunner.failfast {
|
|
||||||
return errors.Wrap(err, "abort running due to failfast setting")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user