I need to skip a scenario from running based on a flag which I obtain from the application dynamically in run-time, which tells whether the feature to be tested is enabled. I don't want to throw any exception.
Sample code:
} else {
status = zapi.getTestExecutionStatusInJIRA(scenario.getName());
if (status.equalsIgnoreCase("pass")) {
isScenarioAlreadyPassed = true;
} else {
isScenarioAlreadyPassed = false;
}
}
} else {
logger.info("Currently JIRA_Integration is disabled, enable it to update test scenario execution status in JIRA");
}
if (isScenarioAlreadyPassed) {
logger.info("Scenario: \"" + scenario.getName() + "\" is already passed in the previous test cycle");
throw new SkipException("\"Scenario: \\\"\" + scenario.getName() + \"\\\" is already passed in the previous test cycle\"");
}
Problem with above approach is failed test still shows up as Error in the test summary. I want these scenario/test to be skipped completely or proceed with next scenario/test.
No assumeTrue also showing as error in result summary
8 Scenarios (1 skipped, 7 passed)
36 Steps (3 skipped, 33 passed)
Thanks for the response Björn.After upgrading cucumber-JVM, cucumber scenario execution status is showing correctly in the terminal. like the one you mentioned.Skipped stepSkipped step1 Scenarios (1 skipped)2 Steps (2 skipped)0m0.535sBut again the problem, maven build is getting failed due to the org.junit.AssumptionViolatedExceptionTests run: 12, Failures: 1, Errors: 0, Skipped: 0[INFO] ------------------------------------------------------------------------[INFO] BUILD FAILURE[INFO] ------------------------------------------------------------------------[INFO] Total time: 8.791 s[INFO] Finished at: 2018-02-03T20:10:08+05:30
8 Scenarios (1 skipped, 7 passed)
36 Steps (3 skipped, 33 passed)
0m0.601s
org.junit.AssumptionViolatedException: got: <false>, expected: is <true>
at org.junit.Assume.assumeThat(Assume.java:95)
at org.junit.Assume.assumeTrue(Assume.java:41)
at cucumber.examples.java.calculator.ShoppingStepdefs.the_following_groceries(ShoppingStepdefs.java:22)
at ✽.the following groceries:(cucumber/examples/java/calculator/shopping.feature:4)
[WARNING] Tests run: 8, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 1.521 s - in cucumber.examples.java.calculator.RunCukesTest
[INFO]
[INFO] Results:
[INFO]
[WARNING] Tests run: 8, Failures: 0, Errors: 0, Skipped: 1
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ java-calculator ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Cucumber-JVM ....................................... SUCCESS [ 0.928 s]
[INFO] Cucumber-JVM: Core ................................. SUCCESS [ 24.236 s]
[INFO] Cucumber-JVM: JUnit ................................ SUCCESS [ 3.881 s]
[INFO] Cucumber-JVM: Java ................................. SUCCESS [ 20.609 s]
[INFO] Examples ........................................... SUCCESS [ 0.052 s]
[INFO] Examples: Java Calculator .......................... SUCCESS [ 4.569 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS