fix(测试计划): 定时任务触发的接口用例执行失败的问题

This commit is contained in:
shiziyuan9527 2021-03-02 14:06:10 +08:00
parent c76a07bc7c
commit 140ce7c211
1 changed files with 9 additions and 3 deletions

View File

@ -486,6 +486,7 @@ public class ApiTestCaseService {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
MsTestElement element = mapper.readValue(testCaseWithBLOBs.getRequest(), new TypeReference<MsTestElement>() {
});
element.setProjectId(testCaseWithBLOBs.getProjectId());
if (StringUtils.isBlank(request.getEnvironmentId())) {
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
example.createCriteria().andTestPlanIdEqualTo(request.getTestPlanId()).andApiCaseIdEqualTo(request.getCaseId());
@ -513,9 +514,14 @@ public class ApiTestCaseService {
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
ApiTestEnvironmentWithBLOBs environment = environmentService.get(request.getEnvironmentId());
ParameterConfig parameterConfig = new ParameterConfig();
// if (environment != null && environment.getConfig() != null) {
// parameterConfig.setConfig(JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class));
// }
Map<String, EnvironmentConfig> envConfig = new HashMap<>(16);
if (environment != null && environment.getConfig() != null) {
EnvironmentConfig environmentConfig = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
envConfig.put(testCaseWithBLOBs.getProjectId(), environmentConfig);
parameterConfig.setConfig(envConfig);
}
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), parameterConfig);
return jmeterHashTree;
}