Skip to content

Commit ef08136

Browse files
committed
karate.abort() and subsequent steps will be set as passed not skipped #755
this is not ideal but because of the behavior of the 3rd party report - see issue details and thread for more
1 parent 6f90774 commit ef08136

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

karate-core/src/main/java/com/intuit/karate/core/Result.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static Result skipped() {
9696
}
9797

9898
public static Result aborted(long nanos) {
99-
return new Result(SKIPPED, nanos, null, true);
99+
return new Result(PASSED, nanos, null, true);
100100
}
101101

102102
public String getStatus() {

karate-core/src/main/java/com/intuit/karate/core/ScenarioExecutionUnit.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class ScenarioExecutionUnit implements Runnable {
4848
private List<Step> steps;
4949
private StepActions actions;
5050
private boolean stopped = false;
51+
private boolean aborted = false;
5152
private StepResult lastStepResult;
5253
private Runnable next;
5354
private boolean last;
@@ -192,13 +193,14 @@ public void reset(ScenarioContext context) {
192193
public StepResult execute(Step step) {
193194
boolean hidden = step.isPrefixStar() && !step.isPrint() && !actions.context.getConfig().isShowAllSteps();
194195
if (stopped) {
195-
return new StepResult(hidden, step, Result.skipped(), null, null, null);
196+
return new StepResult(hidden, step, aborted ? Result.passed(0) : Result.skipped(), null, null, null);
196197
} else {
197198
Result execResult = Engine.executeStep(step, actions);
198199
List<FeatureResult> callResults = actions.context.getAndClearCallResults();
199200
// embed collection for each step happens here
200201
List<Embed> embeds = actions.context.getAndClearEmbeds();
201202
if (execResult.isAborted()) { // we log only aborts for visibility
203+
aborted = true;
202204
actions.context.logger.debug("abort at {}", step.getDebugInfo());
203205
} else if (execResult.isFailed()) {
204206
actions.context.setScenarioError(execResult.getError());

karate-core/src/test/java/com/intuit/karate/core/FeatureResultTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ public void testAbortMultiScenarioFeature() throws Exception {
8888
// skip-pass and skip-fail both should have all steps as skipped
8989
// TODO: generate the expected content string, below code puts a hard dependency
9090
// with KarateJunitFormatter$TestCase.addStepAndResultListing()
91-
assertTrue(contents.contains("* karate.abort() .......................................................... skipped"));
92-
assertTrue(contents.contains("* assert a == 1 ........................................................... skipped"));
93-
assertTrue(contents.contains("* assert a == 2 ........................................................... skipped"));
91+
assertTrue(contents.contains("* karate.abort() .......................................................... passed"));
92+
assertTrue(contents.contains("* assert a == 1 ........................................................... passed"));
93+
assertTrue(contents.contains("* assert a == 2 ........................................................... passed"));
9494

9595
// noskip should have both steps as passed
9696
assertTrue(contents.contains("Then assert a != 3 ........................................................ passed"));

karate-demo/src/test/java/demo/abort/abort.feature

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@ignore
21
Feature: abort should skip (but not fail) a test
32

43
Scenario: you can conditionally exit a test

karate-netty/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ So you have control before and after the actual call, and you can modify the req
570570
# Stopping
571571
A simple HTTP `GET` to `/__admin/stop` is sufficient to stop a running server gracefully. So you don't need to resort to killing the process, which can lead to issues especially on Windows - such as the port not being released.
572572

573+
> Tip: for stopping HTTPS servers, you can use [curl](https://curl.haxx.se) like this: `curl -k https://localhost:8443/__admin/stop`
574+
573575
If you have started the server programmatically via Java, you can keep a reference to the `FeatureServer` instance and call the `stop()` method. Here is an example: [ConsumerUsingMockTest.java](../karate-demo/src/test/java/mock/contract/ConsumerUsingMockTest.java).
574576

575577
# Other Examples

0 commit comments

Comments
 (0)