fix(接口测试): 测试报告展示顺序

This commit is contained in:
chenjianxing 2020-11-24 13:32:03 +08:00
parent 3225a76c43
commit 6bdb76d719
2 changed files with 8 additions and 3 deletions

View File

@ -99,7 +99,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
// 一个脚本里可能包含多个场景(ThreadGroup)所以要区分开key: 场景Id
final Map<String, ScenarioResult> scenarios = new LinkedHashMap<>();
queue.forEach(result -> {
queue.forEach(result -> {
// 线程名称: <场景名> <场景Index>-<请求Index>, 例如Scenario 2-1
String scenarioName = StringUtils.substringBeforeLast(result.getThreadName(), THREAD_SPLIT);
String index = StringUtils.substringAfterLast(result.getThreadName(), THREAD_SPLIT);
@ -107,7 +107,12 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
ScenarioResult scenarioResult;
if (!scenarios.containsKey(scenarioId)) {
scenarioResult = new ScenarioResult();
scenarioResult.setId(scenarioId);
try {
scenarioResult.setId(Integer.parseInt(scenarioId));
} catch (Exception e) {
scenarioResult.setId(0);
LogUtil.error("场景ID转换异常: " + e.getMessage());
}
scenarioResult.setName(scenarioName);
scenarios.put(scenarioId, scenarioResult);
} else {

View File

@ -8,7 +8,7 @@ import java.util.List;
@Data
public class ScenarioResult {
private String id;
private Integer id;
private String name;