fix(接口测试): 完善提取功能

This commit is contained in:
fit2-zhao 2020-09-28 10:48:05 +08:00
parent ccd209880f
commit 34a0f005f3
3 changed files with 6 additions and 6 deletions

View File

@ -154,10 +154,10 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
responseResult.setResponseTime(result.getTime());
responseResult.setResponseMessage(result.getResponseMessage());
if (JMeterVars.variables != null && JMeterVars.variables.get(result.getThreadName()) != null) {
JMeterVars.variables.get(result.getThreadName()).remove("TESTSTART.MS"); //去除系统变量
if (JMeterVars.variables != null && JMeterVars.variables.get(result.hashCode()) != null) {
JMeterVars.variables.get(result.hashCode()).remove("TESTSTART.MS"); //去除系统变量
List<String> vars = new LinkedList<>();
JMeterVars.variables.get(result.getThreadName()).entrySet().parallelStream().reduce(vars, (first, second) -> {
JMeterVars.variables.get(result.hashCode()).entrySet().parallelStream().reduce(vars, (first, second) -> {
first.add(second.getKey() + "" + second.getValue());
return first;
}, (first, second) -> {

View File

@ -10,9 +10,9 @@ import java.util.List;
import java.util.Map;
public class JMeterVars {
public static Map<String, JMeterVariables> variables = new HashMap<>();
public static Map<Integer, JMeterVariables> variables = new HashMap<>();
public static void addVars(String testId, JMeterVariables vars, String extract) {
public static void addVars(Integer testId, JMeterVariables vars, String extract) {
JMeterVariables vs = new JMeterVariables();
if (!StringUtils.isEmpty(extract) && vars != null) {
List<String> extracts = Arrays.asList(extract.split(";"));

View File

@ -1225,7 +1225,7 @@ class JMXGenerator {
vars.push(request.extract.xpath[i].variable);
}
}
request.jsr223PostProcessor.script += "\n" + "io.metersphere.api.jmeter.JMeterVars.addVars(org.apache.jmeter.threads.JMeterContextService.getContext().getThread().getThreadName(),vars," + "\"" + vars.join(";") + "\"" + ");"
request.jsr223PostProcessor.script += "\n" + "io.metersphere.api.jmeter.JMeterVars.addVars(prev.hashCode(),vars," + "\"" + vars.join(";") + "\"" + ");"
sampler.put(new JSR223PostProcessor(name, request.jsr223PostProcessor));
}