@@ -15,21 +15,21 @@ class CucumberTest extends CiVisibilityInstrumentationTest {
1515 def runner = new JUnitCore ()
1616
1717 def " test #testcaseName" () {
18- runFeatures(features)
18+ runFeatures(features, success )
1919
2020 assertSpansData(testcaseName)
2121
2222 where :
23- testcaseName | features
24- " test-succeed" | [" org/example/cucumber/calculator/basic_arithmetic.feature" ]
25- " test-scenario-outline-${ version()} " | [" org/example/cucumber/calculator/basic_arithmetic_with_examples.feature" ]
26- " test-failure" | [" org/example/cucumber/calculator/basic_arithmetic_failed.feature" ]
27- " test-multiple-features-${ version()} " | [
23+ testcaseName | success | features
24+ " test-succeed" | true | [" org/example/cucumber/calculator/basic_arithmetic.feature" ]
25+ " test-scenario-outline-${ version()} " | true | [" org/example/cucumber/calculator/basic_arithmetic_with_examples.feature" ]
26+ " test-failure" | false | [" org/example/cucumber/calculator/basic_arithmetic_failed.feature" ]
27+ " test-multiple-features-${ version()} " | false | [
2828 " org/example/cucumber/calculator/basic_arithmetic.feature" ,
2929 " org/example/cucumber/calculator/basic_arithmetic_failed.feature"
3030 ]
31- " test-name-with-brackets" | [" org/example/cucumber/calculator/name_with_brackets.feature" ]
32- " test-empty-name-${ version()} " | [" org/example/cucumber/calculator/empty_scenario_name.feature" ]
31+ " test-name-with-brackets" | true | [" org/example/cucumber/calculator/name_with_brackets.feature" ]
32+ " test-empty-name-${ version()} " | true | [" org/example/cucumber/calculator/empty_scenario_name.feature" ]
3333 }
3434
3535 def " test ITR #testcaseName" () {
@@ -56,17 +56,17 @@ class CucumberTest extends CiVisibilityInstrumentationTest {
5656 givenFlakyRetryEnabled(true )
5757 givenFlakyTests(retriedTests)
5858
59- runFeatures(features)
59+ runFeatures(features, success )
6060
6161 assertSpansData(testcaseName)
6262
6363 where :
64- testcaseName | features | retriedTests
65- " test-failure" | [" org/example/cucumber/calculator/basic_arithmetic_failed.feature" ] | []
66- " test-retry-failure" | [" org/example/cucumber/calculator/basic_arithmetic_failed.feature" ] | [
64+ testcaseName | success | features | retriedTests
65+ " test-failure" | false | [" org/example/cucumber/calculator/basic_arithmetic_failed.feature" ] | []
66+ " test-retry-failure" | false | [" org/example/cucumber/calculator/basic_arithmetic_failed.feature" ] | [
6767 new TestIdentifier (" classpath:org/example/cucumber/calculator/basic_arithmetic_failed.feature:Basic Arithmetic" , " Addition" , null )
6868 ]
69- " test-retry-scenario-outline-${ version()} " | [" org/example/cucumber/calculator/basic_arithmetic_with_examples_failed.feature" ] | [
69+ " test-retry-scenario-outline-${ version()} " | false | [" org/example/cucumber/calculator/basic_arithmetic_with_examples_failed.feature" ] | [
7070 new TestIdentifier (" classpath:org/example/cucumber/calculator/basic_arithmetic_with_examples_failed.feature:Basic Arithmetic With Examples" , " Many additions" , null )
7171 ]
7272 }
@@ -93,16 +93,28 @@ class CucumberTest extends CiVisibilityInstrumentationTest {
9393 return CucumberTracingListener . FRAMEWORK_VERSION < " 7" ? CucumberTracingListener . FRAMEWORK_VERSION : " latest"
9494 }
9595
96- private void runFeatures (List<String > classpathFeatures ) {
96+ private void runFeatures (List<String > classpathFeatures , boolean expectSuccess = true ) {
9797 System . setProperty(Constants . GLUE_PROPERTY_NAME , " org.example.cucumber.calculator" )
9898 System . setProperty(Constants . FILTER_TAGS_PROPERTY_NAME , " not @Disabled" )
9999 System . setProperty(Constants . FEATURES_PROPERTY_NAME , classpathFeatures. stream()
100100 .map(f -> " classpath:" + f).
101101 collect(Collectors . joining(" ," )))
102102
103103 TestEventsHandlerHolder . start()
104- runner. run(TestSucceedCucumber )
105- TestEventsHandlerHolder . stop()
104+ try {
105+ def result = runner. run(TestSucceedCucumber )
106+ if (expectSuccess) {
107+ if (result. getFailureCount() > 0 ) {
108+ throw new AssertionError (" Expected successful execution, got following failures: " + result. getFailures())
109+ }
110+ } else {
111+ if (result. getFailureCount() == 0 ) {
112+ throw new AssertionError (" Expected a failed execution, got no failures" )
113+ }
114+ }
115+ } finally {
116+ TestEventsHandlerHolder . stop()
117+ }
106118 }
107119
108120 @Override
0 commit comments