fix(接口测试): 修复场景变量不选任何策略时,默认执行取参错误问题

--bug=1020890 --user=赵勇 【接口测试】场景引用其他场景,场景设置中都不勾选,变量引用了原场景变量 https://www.tapd.cn/55049933/s/1316024
This commit is contained in:
fit2-zhao 2022-12-15 18:20:17 +08:00 committed by 刘瑞斌
parent 483a8b4a3e
commit 288fb32aab
3 changed files with 8 additions and 10 deletions

View File

@ -122,18 +122,16 @@ public class MsScenario extends MsTestElement {
// 环境变量 // 环境变量
Arguments arguments = ElementUtil.getConfigArguments(this.isEnvironmentEnable() ? Arguments arguments = ElementUtil.getConfigArguments(this.isEnvironmentEnable() ?
newConfig : config, this.getName(), this.getProjectId(), this.getVariables()); newConfig : config, this.getName(), this.getProjectId(), this.getVariables());
if (arguments != null && ((this.variableEnable == null || this.variableEnable) if (arguments != null && !arguments.getArguments().isEmpty()) {
|| (this.mixEnable == null || this.mixEnable))) {
Arguments valueSupposeMock = ParameterConfig.valueSupposeMock(arguments); Arguments valueSupposeMock = ParameterConfig.valueSupposeMock(arguments);
// 这里加入自定义变量解决ForEach循环控制器取值问题循环控制器无法从vars中取值 // 这里加入自定义变量解决ForEach循环控制器取值问题循环控制器无法从vars中取值
if ((this.variableEnable == null || this.variableEnable) if (BooleanUtils.isTrue(this.variableEnable) || BooleanUtils.isTrue(this.mixEnable)) {
|| (this.mixEnable == null || this.mixEnable)) {
scenarioTree.add(ElementUtil.argumentsToUserParameters(valueSupposeMock)); scenarioTree.add(ElementUtil.argumentsToUserParameters(valueSupposeMock));
} else { } else if (config != null && StringUtils.equals(this.getId(), config.getScenarioId())) {
scenarioTree.add(valueSupposeMock); scenarioTree.add(valueSupposeMock);
} }
} }
if (this.variableEnable == null || this.variableEnable) { if (BooleanUtils.isTrue(this.variableEnable) || BooleanUtils.isTrue(this.mixEnable)) {
ElementUtil.addCsvDataSet(scenarioTree, variables, this.isEnvironmentEnable() ? newConfig : config, "shareMode.group"); ElementUtil.addCsvDataSet(scenarioTree, variables, this.isEnvironmentEnable() ? newConfig : config, "shareMode.group");
ElementUtil.addCounter(scenarioTree, variables); ElementUtil.addCounter(scenarioTree, variables);
ElementUtil.addRandom(scenarioTree, variables); ElementUtil.addRandom(scenarioTree, variables);

View File

@ -30,9 +30,9 @@ public class MsKafkaListener {
@Resource @Resource
private TestResultService testResultService; private TestResultService testResultService;
// 线程池维护线程的最少数量 // 线程池维护线程的最少数量
private final static int CORE_POOL_SIZE = 20; private final static int CORE_POOL_SIZE = 5;
// 线程池维护线程的最大数量 // 线程池维护线程的最大数量
private final static int MAX_POOL_SIZE = 20; private final static int MAX_POOL_SIZE = 5;
// 线程池维护线程所允许的空闲时间 // 线程池维护线程所允许的空闲时间
private final static int KEEP_ALIVE_TIME = 1; private final static int KEEP_ALIVE_TIME = 1;
// 线程池所使用的缓冲队列大小 // 线程池所使用的缓冲队列大小

View File

@ -421,7 +421,7 @@ public class FileUtils {
public static byte[] fileToByte(File tradeFile) { public static byte[] fileToByte(File tradeFile) {
byte[] buffer = null; byte[] buffer = null;
try (FileInputStream fis = new FileInputStream(tradeFile); try (FileInputStream fis = new FileInputStream(tradeFile);
ByteArrayOutputStream bos = new ByteArrayOutputStream();) { ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
byte[] b = new byte[1024]; byte[] b = new byte[1024];
int n; int n;
while ((n = fis.read(b)) != -1) { while ((n = fis.read(b)) != -1) {
@ -429,7 +429,7 @@ public class FileUtils {
} }
buffer = bos.toByteArray(); buffer = bos.toByteArray();
} catch (Exception e) { } catch (Exception e) {
LoggerUtil.error(e); LogUtil.error(e);
} }
return buffer; return buffer;
} }