Skip to content

Commit

Permalink
Scenario manager - support loading test scenario files from child fol…
Browse files Browse the repository at this point in the history
…ders recursively #1337
  • Loading branch information
greenlaw110 committed May 24, 2020
1 parent a0e00c4 commit af61bbf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,6 +1,7 @@
# ActFramework Change Log

##1.8.33**
* Scenario manager - support loading test scenario files from child folders recursively #1337
* Param value loader framework - allow inject another controller class #1336
* `EnhancedAdaptiveMap.asMap(EnhancedAdaptiveMap)` generated `Map` shall implement hashCode and equals methods #1333
* Session cache shall be cleared after app hot reload #1330 - update osgl-http to 1.13.2
Expand Down
17 changes: 7 additions & 10 deletions src/main/java/act/test/TestSession.java
Expand Up @@ -414,26 +414,23 @@ private Object getVal(String key) {
}
}
}
key = S.underscore(key);
o = constants.get(key);
String underscoredKey = S.underscore(key);
o = constants.get(underscoredKey);
if (null != o) {
return o;
}
o = Test.constant(key);
o = Test.constant(underscoredKey);
if (null != o) {
return o;
}
try {
return evalFunc(key);
} catch (Exception e) {
if (!"last".equals(key)) {
try {
return getVal("last", key);
} catch (Exception e1) {
throw E.unexpected("Unable to get value by key: %s", key);
}
try {
return getLastVal(key);
} catch (Exception e1) {
throw E.unexpected("Unable to get value by key: %s", key);
}
return null;
}
}

Expand Down
34 changes: 18 additions & 16 deletions src/main/java/act/test/util/ScenarioManager.java
Expand Up @@ -147,26 +147,28 @@ private void searchScenarioFolder() {
}

private void loadFromScenarioDir(File scenariosDir) {
File[] ymlFiles = scenariosDir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".yml");
}
});
File[] ymlFiles = scenariosDir.listFiles();
if (null == ymlFiles) {
return;
}
for (File file : ymlFiles) {
String content = IO.read(file).toString();
if (S.blank(content)) {
warn("Empty yaml file found: " + file.getPath());
continue;
}
try {
parseOne(content, file.getAbsolutePath());
} catch (RuntimeException e) {
error(e, "Error parsing scenario file: %s", file.getName());
throw e;
if (file.isDirectory()) {
loadFromScenarioDir(file);
} else {
String fileName = file.getName();
if (fileName.endsWith(".yml") || fileName.endsWith(".yaml")) {
String content = IO.read(file).toString();
if (S.blank(content)) {
warn("Empty yaml file found: " + file.getPath());
continue;
}
try {
parseOne(content, file.getAbsolutePath());
} catch (RuntimeException e) {
error(e, "Error parsing scenario file: %s", file.getName());
throw e;
}
}
}
}
}
Expand Down

0 comments on commit af61bbf

Please sign in to comment.