fix(接口定义): 修复批量执行接口用例结果未拿到问题

This commit is contained in:
fit2-zhao 2021-07-22 10:49:03 +08:00 committed by fit2-zhao
parent 2c16f3f845
commit c95e4742ce
1 changed files with 15 additions and 9 deletions

View File

@ -61,15 +61,21 @@ public class ApiDefinitionExecResultService {
if (CollectionUtils.isNotEmpty(result.getScenarios())) {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
ApiDefinitionExecResultMapper definitionExecResultMapper = sqlSession.getMapper(ApiDefinitionExecResultMapper.class);
final boolean[] isFirst = {true};
result.getScenarios().forEach(scenarioResult -> {
if (scenarioResult != null && CollectionUtils.isNotEmpty(scenarioResult.getRequestResults())) {
scenarioResult.getRequestResults().forEach(item -> {
ApiDefinitionExecResult saveResult = definitionExecResultMapper.selectByPrimaryKey(result.getTestId());
item.getResponseResult().setConsole(result.getConsole());
boolean saved = true;
if (saveResult == null) {
if (saveResult == null || scenarioResult.getRequestResults().size() > 1) {
saveResult = new ApiDefinitionExecResult();
if (isFirst[0]) {
isFirst[0] = false;
saveResult.setId(result.getTestId());
} else {
saveResult.setId(UUID.randomUUID().toString());
}
saveResult.setActuator("LOCAL");
saveResult.setName(item.getName());
saveResult.setTriggerMode(triggerMode);