Skip to content

Commit

Permalink
refactor: renamed runner field per Peter's comments
Browse files Browse the repository at this point in the history
Renamed ignoreJunitNoScenariosAssertion to failWhenNoScenariosFound.

Refs: #2531
  • Loading branch information
dustin committed Mar 13, 2024
1 parent 74d94ca commit d089d81
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
10 changes: 6 additions & 4 deletions karate-core/src/main/java/com/intuit/karate/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static class Builder<T extends Builder> {
boolean outputCucumberJson;
boolean dryRun;
boolean debugMode;
boolean ignoreJunitNoScenariosAssertion;
boolean failWhenNoScenariosFound;
Map<String, String> systemProperties;
Map<String, Object> callSingleCache;
Map<String, ScenarioCall.Result> callOnceCache;
Expand Down Expand Up @@ -147,7 +147,7 @@ public synchronized Builder copy() {
b.outputCucumberJson = outputCucumberJson;
b.dryRun = dryRun;
b.debugMode = debugMode;
b.ignoreJunitNoScenariosAssertion = ignoreJunitNoScenariosAssertion;
b.failWhenNoScenariosFound = failWhenNoScenariosFound;
b.systemProperties = systemProperties;
b.callSingleCache = callSingleCache;
b.callOnceCache = callOnceCache;
Expand Down Expand Up @@ -439,10 +439,12 @@ public T debugMode(boolean value) {
debugMode = value;
return (T) this;
}
public T ignoreJunitNoScenariosAssertion(boolean value) {
ignoreJunitNoScenariosAssertion = value;

public T failWhenNoScenariosFound(boolean value) {
failWhenNoScenariosFound = value;
return (T) this;
}

public T callSingleCache(Map<String, Object> value) {
callSingleCache = value;
return (T) this;
Expand Down
6 changes: 3 additions & 3 deletions karate-core/src/main/java/com/intuit/karate/Suite.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class Suite implements Runnable {
public final String tagSelector;
public final boolean dryRun;
public final boolean debugMode;
public final boolean ignoreJunitNoScenariosAssertion;
public final boolean failWhenNoScenariosFound;
public final File workingDir;
public final String buildDir;
public final String reportDir;
Expand Down Expand Up @@ -130,7 +130,7 @@ public Suite(Runner.Builder rb) {
if (rb.forTempUse) {
dryRun = false;
debugMode = false;
ignoreJunitNoScenariosAssertion = false;
failWhenNoScenariosFound = false;
backupReportDir = false;
outputHtmlReport = false;
outputCucumberJson = false;
Expand Down Expand Up @@ -175,7 +175,7 @@ public Suite(Runner.Builder rb) {
outputJunitXml = rb.outputJunitXml;
dryRun = rb.dryRun;
debugMode = rb.debugMode;
ignoreJunitNoScenariosAssertion = rb.ignoreJunitNoScenariosAssertion;
failWhenNoScenariosFound = rb.failWhenNoScenariosFound;
classLoader = rb.classLoader;
clientFactory = rb.clientFactory;
env = rb.env;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public Iterator<DynamicNode> iterator() {
DynamicNode node = DynamicContainer.dynamicContainer(testName, featureNode);
list.add(node);
}
if (!suite.ignoreJunitNoScenariosAssertion && list.isEmpty()) {
if (suite.failWhenNoScenariosFound && list.isEmpty()) {
Assertions.fail("no features or scenarios found: " + this);
}
return list.iterator();
Expand Down
10 changes: 5 additions & 5 deletions karate-junit5/src/test/java/karate/NoFeatureNoScenarioTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
class NoFeatureNoScenarioTest {

@Karate.Test
Karate testValidTagWithIgnoreJunitNoScenarioAssertion() {
Karate testHasScenariosWithFailWhenNoScenariosFound() {
return Karate.run("noFeatureNoScenario")
.tags("@smoke")
.ignoreJunitNoScenariosAssertion(true)
.failWhenNoScenariosFound(true)
.relativeTo(getClass());
}

@Karate.Test
Karate testInvalidTagWithIgnoreJunitNoScenarioAssertion() {
Karate testNoScenarios() {
return Karate.run("noFeatureNoScenario")
.tags("@tagnotexist")
.ignoreJunitNoScenariosAssertion(true)
.failWhenNoScenariosFound(false)
.relativeTo(getClass());
}

}

0 comments on commit d089d81

Please sign in to comment.