@@ -23,6 +23,27 @@ def bar() {
2323 result. testsSucceededCount == 0
2424 }
2525
26+ def " @PendingFeatureIf marks failing feature as skipped if the condition passes and the test fails even if applied twice" () {
27+ when :
28+ def result = runner. runWithImports(""" import spock.lang.PendingFeature
29+ import spock.lang.PendingFeatureIf
30+
31+ class Foo extends Specification {
32+ @PendingFeatureIf({true})
33+ @PendingFeatureIf({true})
34+ def bar() {
35+ expect: false
36+ }
37+ }
38+ """ )
39+
40+ then :
41+ notThrown(AssertionError )
42+ result. runCount == 1
43+ result. failureCount == 0
44+ result. ignoreCount == 0
45+ }
46+
2647 def " @PendingFeatureIf marks passing feature as failed if the conditional expression returns true" () {
2748 when :
2849 runner. runSpecBody """
@@ -37,6 +58,24 @@ def bar() {
3758 e. message == " Feature is marked with @PendingFeatureIf but passes unexpectedly"
3859 }
3960
61+ def " @PendingFeatureIf marks passing feature as failed if the conditional expression returns true even if applied twice" () {
62+ when :
63+ def result = runner. runWithImports(""" import spock.lang.PendingFeature
64+ import spock.lang.PendingFeatureIf
65+
66+ class Foo extends Specification {
67+ @PendingFeatureIf({true})
68+ @PendingFeatureIf({true})
69+ def bar() {
70+ expect: true
71+ }
72+ }
73+ """ )
74+ then :
75+ AssertionError e = thrown(AssertionError )
76+ e. message == " Feature is marked with @PendingFeatureIf but passes unexpectedly"
77+ }
78+
4079 def " @PendingFeatureIf marks passing feature as failed if the conditional expression returns true even if @PendingFeature is applied first" () {
4180 when :
4281 runner. runSpecBody """
@@ -182,6 +221,26 @@ def bar() {
182221 result. testsSucceededCount == 1
183222 }
184223
224+ def " @PendingFeatureIf marks failing feature as skipped if the data variable accessing condition passes and the test fails even if applied twice" () {
225+ when :
226+ def result = runner. runSpecBody """
227+ @PendingFeatureIf({ a == 1 })
228+ @PendingFeatureIf({ a == 1 })
229+ def bar() {
230+ expect: a == 2
231+ where: a = 1
232+ }
233+ """
234+
235+ then :
236+ notThrown(AssertionError )
237+ result. testsStartedCount == 2
238+ result. testsFailedCount == 0
239+ result. testsSkippedCount == 0
240+ result. testsAbortedCount == 1
241+ result. testsSucceededCount == 1
242+ }
243+
185244 def " @PendingFeatureIf marks passing feature as failed if the data variable accessing conditional expression returns true" () {
186245 when :
187246 runner. runSpecBody """
@@ -197,6 +256,22 @@ def bar() {
197256 e. message == " Feature is marked with @PendingFeatureIf but passes unexpectedly"
198257 }
199258
259+ def " @PendingFeatureIf marks passing feature as failed if the data variable accessing conditional expression returns true even if applied twice" () {
260+ when :
261+ runner. runSpecBody """
262+ @PendingFeatureIf({ a == 2 })
263+ @PendingFeatureIf({ a == 2 })
264+ def bar() {
265+ expect: a == 2
266+ where: a = 2
267+ }
268+ """
269+
270+ then :
271+ AssertionError e = thrown()
272+ e. message == " Feature is marked with @PendingFeatureIf but passes unexpectedly"
273+ }
274+
200275 def " @PendingFeatureIf marks failing feature as failed if the data variable accessing conditional expression returns false" () {
201276 when :
202277 runner. runSpecBody """
0 commit comments