@@ -15,21 +15,21 @@ class CucumberTest extends CiVisibilityInstrumentationTest {
15
15
def runner = new JUnitCore ()
16
16
17
17
def " test #testcaseName" () {
18
- runFeatures(features)
18
+ runFeatures(features, success )
19
19
20
20
assertSpansData(testcaseName)
21
21
22
22
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 | [
28
28
" org/example/cucumber/calculator/basic_arithmetic.feature" ,
29
29
" org/example/cucumber/calculator/basic_arithmetic_failed.feature"
30
30
]
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" ]
33
33
}
34
34
35
35
def " test ITR #testcaseName" () {
@@ -56,17 +56,17 @@ class CucumberTest extends CiVisibilityInstrumentationTest {
56
56
givenFlakyRetryEnabled(true )
57
57
givenFlakyTests(retriedTests)
58
58
59
- runFeatures(features)
59
+ runFeatures(features, success )
60
60
61
61
assertSpansData(testcaseName)
62
62
63
63
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" ] | [
67
67
new TestIdentifier (" classpath:org/example/cucumber/calculator/basic_arithmetic_failed.feature:Basic Arithmetic" , " Addition" , null )
68
68
]
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" ] | [
70
70
new TestIdentifier (" classpath:org/example/cucumber/calculator/basic_arithmetic_with_examples_failed.feature:Basic Arithmetic With Examples" , " Many additions" , null )
71
71
]
72
72
}
@@ -93,16 +93,28 @@ class CucumberTest extends CiVisibilityInstrumentationTest {
93
93
return CucumberTracingListener . FRAMEWORK_VERSION < " 7" ? CucumberTracingListener . FRAMEWORK_VERSION : " latest"
94
94
}
95
95
96
- private void runFeatures (List<String > classpathFeatures ) {
96
+ private void runFeatures (List<String > classpathFeatures , boolean expectSuccess = true ) {
97
97
System . setProperty(Constants . GLUE_PROPERTY_NAME , " org.example.cucumber.calculator" )
98
98
System . setProperty(Constants . FILTER_TAGS_PROPERTY_NAME , " not @Disabled" )
99
99
System . setProperty(Constants . FEATURES_PROPERTY_NAME , classpathFeatures. stream()
100
100
.map(f -> " classpath:" + f).
101
101
collect(Collectors . joining(" ," )))
102
102
103
103
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
+ }
106
118
}
107
119
108
120
@Override
0 commit comments