mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
fix: extract variables
This commit is contained in:
@@ -87,10 +87,11 @@ func (v *ResponseObject) Extract(extractors map[string]string) map[string]interf
|
||||
|
||||
extractMapping := make(map[string]interface{})
|
||||
for key, value := range extractors {
|
||||
extractMapping[key] = v.searchJmespath(value)
|
||||
extractedValue := v.searchJmespath(value)
|
||||
log.Printf("extract %s => %v", value, extractedValue)
|
||||
extractMapping[key] = extractedValue
|
||||
}
|
||||
|
||||
log.Printf("[Extract] extractMapping: %v", extractMapping)
|
||||
return extractMapping
|
||||
}
|
||||
|
||||
|
||||
@@ -140,8 +140,11 @@ func (r *Runner) runStepRequest(step *TStep) (stepData *StepData, err error) {
|
||||
extractMapping := respObj.Extract(extractors)
|
||||
stepData.ExportVars = extractMapping
|
||||
|
||||
// override step variables with extracted variables
|
||||
stepVariables := mergeVariables(step.Variables, extractMapping)
|
||||
|
||||
// validate response
|
||||
err = respObj.Validate(step.Validators, step.Variables)
|
||||
err = respObj.Validate(step.Validators, stepVariables)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user