fix: 失败继续无效

This commit is contained in:
chenjianxing 2021-06-22 18:35:25 +08:00 committed by jianxing
parent 10ac86a0a0
commit 4aae311024
5 changed files with 10 additions and 10 deletions

View File

@ -62,7 +62,7 @@ public class MsScenario extends MsTestElement {
private Map<String, String> environmentMap;
@JSONField(ordinal = 24)
private boolean onSampleError;
private Boolean onSampleError;
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;

View File

@ -21,7 +21,7 @@ import java.util.List;
public class MsThreadGroup extends MsTestElement {
private String type = "ThreadGroup";
private boolean enableCookieShare;
private boolean onSampleError;
private Boolean onSampleError;
@Override
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
@ -66,7 +66,7 @@ public class MsThreadGroup extends MsTestElement {
threadGroup.setDuration(0);
threadGroup.setProperty(ThreadGroup.ON_SAMPLE_ERROR, ThreadGroup.ON_SAMPLE_ERROR_CONTINUE);
threadGroup.setScheduler(false);
if (!onSampleError) {
if (onSampleError != null && !onSampleError) {
threadGroup.setProperty("ThreadGroup.on_sample_error", "stoptest");
}
threadGroup.setSamplerController(loopController);

View File

@ -33,7 +33,7 @@ public class ParameterConfig {
/**
* 是否停止继续
*/
private boolean onSampleError;
private Boolean onSampleError;
/**
* 是否是导入/导出操作
@ -62,4 +62,4 @@ public class ParameterConfig {
return arguments;
}
}
}

View File

@ -785,7 +785,7 @@ public class ApiAutomationService {
group.setLabel(item.getName());
group.setName(reportId);
MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class);
group.setOnSampleError(scenario.isOnSampleError());
group.setOnSampleError(scenario.getOnSampleError());
this.preduceMsScenario(scenario);
if (planEnvMap.size() > 0) {
scenario.setEnvironmentMap(planEnvMap);
@ -829,7 +829,7 @@ public class ApiAutomationService {
group.setLabel(apiScenario.getName());
group.setName(apiScenario.getName());
group.setEnableCookieShare(scenario.isEnableCookieShare());
group.setOnSampleError(scenario.isOnSampleError());
group.setOnSampleError(scenario.getOnSampleError());
group.setHashTree(new LinkedList<MsTestElement>() {{
this.add(scenario);
}});
@ -1062,7 +1062,7 @@ public class ApiAutomationService {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JSONObject element = JSON.parseObject(item.getScenarioDefinition());
MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class);
group.setOnSampleError(scenario.isOnSampleError());
group.setOnSampleError(scenario.getOnSampleError());
this.preduceMsScenario(scenario);
// 多态JSON普通转换会丢失内容需要通过 ObjectMapper 获取
if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
@ -1078,7 +1078,7 @@ public class ApiAutomationService {
scenario.setVariables(variables);
}
group.setEnableCookieShare(scenario.isEnableCookieShare());
group.setOnSampleError(scenario.isOnSampleError());
group.setOnSampleError(scenario.getOnSampleError());
LinkedList<MsTestElement> scenarios = new LinkedList<>();
scenarios.add(scenario);
// 创建场景报告

View File

@ -969,7 +969,7 @@ public class TestPlanService {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JSONObject element = JSON.parseObject(item.getScenarioDefinition());
MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class);
group.setOnSampleError(scenario.isOnSampleError());
group.setOnSampleError(scenario.getOnSampleError());
// 多态JSON普通转换会丢失内容需要通过 ObjectMapper 获取
if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"),