mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-09 01:39:39 +08:00
feat: data-driven.
This commit is contained in:
11
boomer.go
11
boomer.go
@@ -1,9 +1,10 @@
|
|||||||
package hrp
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jinzhu/copier"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/jinzhu/copier"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"github.com/httprunner/hrp/internal/boomer"
|
"github.com/httprunner/hrp/internal/boomer"
|
||||||
@@ -70,17 +71,17 @@ func (b *hrpBoomer) convertBoomerTask(testcase *TestCase) *boomer.Task {
|
|||||||
var transactionSuccess = true // flag current transaction result
|
var transactionSuccess = true // flag current transaction result
|
||||||
|
|
||||||
cfg := testcase.Config.ToStruct()
|
cfg := testcase.Config.ToStruct()
|
||||||
testCaseVariables := &TConfig{}
|
caseConfig := &TConfig{}
|
||||||
// copy config to avoid data racing
|
// copy config to avoid data racing
|
||||||
if err := copier.Copy(testCaseVariables, cfg); err != nil {
|
if err := copier.Copy(caseConfig, cfg); err != nil {
|
||||||
log.Error().Err(err).Msg("copy config data failed")
|
log.Error().Err(err).Msg("copy config data failed")
|
||||||
}
|
}
|
||||||
if it := cfg.ParametersSetting.Iterator; it.HasNext() {
|
if it := cfg.ParametersSetting.Iterator; it.HasNext() {
|
||||||
testCaseVariables.Variables = mergeVariables(it.Next(), cfg.Variables)
|
caseConfig.Variables = mergeVariables(it.Next(), cfg.Variables)
|
||||||
}
|
}
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
for index, step := range testcase.TestSteps {
|
for index, step := range testcase.TestSteps {
|
||||||
stepData, err := runner.runStep(index, testCaseVariables)
|
stepData, err := runner.runStep(index, caseConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// step failed
|
// step failed
|
||||||
var elapsed int64
|
var elapsed int64
|
||||||
|
|||||||
Reference in New Issue
Block a user