Skip to content

Commit

Permalink
code improvement related to #1502
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Mar 6, 2021
1 parent 83f5741 commit aa4ed47
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 6 additions & 0 deletions karate-core/src/main/java/com/intuit/karate/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public static class Builder {
boolean outputJunitXml;
boolean outputCucumberJson;
boolean dryRun;
boolean debugMode;
Map<String, String> systemProperties;
Map<String, Object> suiteCache;
SuiteReports suiteReports;
Expand Down Expand Up @@ -485,6 +486,11 @@ public Builder dryRun(boolean value) {
dryRun = value;
return this;
}

public Builder debugMode(boolean value) {
debugMode = value;
return this;
}

public Builder suiteCache(Map<String, Object> value) {
suiteCache = value;
Expand Down
3 changes: 3 additions & 0 deletions karate-core/src/main/java/com/intuit/karate/Suite.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class Suite implements Runnable {
public final String env;
public final String tagSelector;
public final boolean dryRun;
public final boolean debugMode;
public final File workingDir;
public final String buildDir;
public final String reportDir;
Expand Down Expand Up @@ -124,6 +125,7 @@ public Suite() {
public Suite(Runner.Builder rb) {
if (rb.forTempUse) {
dryRun = false;
debugMode = false;
backupReportDir = false;
outputHtmlReport = false;
outputCucumberJson = false;
Expand Down Expand Up @@ -162,6 +164,7 @@ public Suite(Runner.Builder rb) {
outputCucumberJson = rb.outputCucumberJson;
outputJunitXml = rb.outputJunitXml;
dryRun = rb.dryRun;
debugMode = rb.debugMode;
classLoader = rb.classLoader;
clientFactory = rb.clientFactory;
env = rb.env;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ public void beforeRun() {
evalConfigJs(featureRuntime.suite.karateConfig, "karate-config.js");
evalConfigJs(featureRuntime.suite.karateConfigEnv, "karate-config-" + featureRuntime.suite.env + ".js");
}
if (background == null) {
if (background == null || scenario.isOutlineExample()) {
featureRuntime.suite.hooks.forEach(h -> h.beforeScenario(this));
} else {
} else if (featureRuntime.suite.debugMode) {
featureRuntime.suite.hooks.stream()
.filter(DebugThread.class::isInstance)
.forEach(h -> h.beforeScenario(this));
Expand Down Expand Up @@ -394,14 +394,12 @@ public void run() {
} finally {
if (!scenario.isDynamic()) { // don't add "fake" scenario to feature results
afterRun();
} else {
} else if (featureRuntime.suite.debugMode) {
// if it's a dynamic scenario running under the debugger
// we still want to execute the afterScenario() hook of the debugger server
if (!dryRun) {
featureRuntime.suite.hooks.stream()
.filter(DebugThread.class::isInstance)
.forEach(h -> h.afterScenario(this));
}
featureRuntime.suite.hooks.stream()
.filter(DebugThread.class::isInstance)
.forEach(h -> h.afterScenario(this));
}
if (caller.isNone()) {
logAppender.close(); // reclaim memory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ private void start() {
}
runnerThread = new Thread(() -> {
Runner.path(options.getPaths())
.debugMode(true)
.hookFactory(this)
.hooks(options.createHooks())
.tags(options.getTags())
Expand Down

0 comments on commit aa4ed47

Please sign in to comment.