fix(接口自动化): 设置共享模式解决 循环 csv 从第二行取值问题

This commit is contained in:
fit2-zhao 2021-05-07 15:17:04 +08:00 committed by fit2-zhao
parent ae624768b3
commit 6567dd2ec7
3 changed files with 4 additions and 5 deletions

View File

@ -156,7 +156,7 @@ public class MsScenario extends MsTestElement {
if (arguments != null) {
tree.add(ParameterConfig.valueSupposeMock(arguments));
}
this.addCsvDataSet(tree, variables,config);
this.addCsvDataSet(tree, variables, config, "shareMode.group");
this.addCounter(tree, variables);
this.addRandom(tree, variables);
if (CollectionUtils.isNotEmpty(this.headers)) {

View File

@ -188,7 +188,7 @@ public abstract class MsTestElement {
return null;
}
protected void addCsvDataSet(HashTree tree, List<ScenarioVariable> variables, ParameterConfig config) {
protected void addCsvDataSet(HashTree tree, List<ScenarioVariable> variables, ParameterConfig config, String shareMode) {
if (CollectionUtils.isNotEmpty(variables)) {
List<ScenarioVariable> list = variables.stream().filter(ScenarioVariable::isCSVValid).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(list)) {
@ -206,8 +206,7 @@ public abstract class MsTestElement {
csvDataSet.setProperty("filename", BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName());
}
csvDataSet.setIgnoreFirstLine(false);
// csvDataSet.setProperty("quotedData",true);
csvDataSet.setProperty("shareMode", "shareMode.group");
csvDataSet.setProperty("shareMode", shareMode);
csvDataSet.setProperty("recycle", true);
csvDataSet.setProperty("delimiter", item.getDelimiter());
csvDataSet.setComment(StringUtils.isEmpty(item.getDescription()) ? "" : item.getDescription());

View File

@ -56,7 +56,7 @@ public class MsLoopController extends MsTestElement {
}
final HashTree groupTree = controller(tree);
if (CollectionUtils.isNotEmpty(config.getVariables())) {
this.addCsvDataSet(groupTree, config.getVariables(), config);
this.addCsvDataSet(groupTree, config.getVariables(), config, "shareMode.thread");
this.addCounter(groupTree, config.getVariables());
this.addRandom(groupTree, config.getVariables());
}