I am trying to add a functionality in my stack where I would only run specific scenarios which path and line are stored in my database. These scenarios would be injected to the TestRunner file.
@Test
@SuppressWarnings("unchecked")
public void testParallel() {
Assertions.assertThat(Runtime.version().feature())
.as("Java version should be 11").isEqualTo(11);
// Pretend this getting scenarios from DB
List<String> paths = new ArrayList<>();
paths.add("src/test/java/feature/test.feature:4");
paths.add("src/test/java/feature/test.feature:12");
Builder runnerBuilder = new Builder();
runnerBuilder.path(paths);
runnerBuilder.outputCucumberJson(true);
runnerBuilder.outputJunitXml(true);
runnerBuilder.hooks(getKarateHooks());
Results results = runnerBuilder.parallel(1);
...
}
When I run this, there's no scenarios executed at all. But when I feed the list with just one scenario path it can run that one scenario. Not sure what's wrong with it. The path method can accept either a string or a list. So I would assume this is how you run multiple scenarios with path. But I got no luck.
These are the path methods in Runner.class in karate-core:
public T path(String... value) {
this.path(Arrays.asList(value));
return this;
}
public T path(List<String> value) {
if (value != null) {
if (this.paths == null) {
this.paths = new ArrayList();
}
this.paths.addAll(value);
}
return this;
}