-
Notifications
You must be signed in to change notification settings - Fork 469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make @PendingFeature repeatable (#1030) #1190
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.spockframework.docs.extension | ||
|
||
import spock.lang.PendingFeature | ||
import spock.lang.PendingFeatureIf | ||
import spock.lang.Specification | ||
|
||
class PendingFeatureDocSpec extends Specification { | ||
// tag::example-a[] | ||
@PendingFeature | ||
def "not implemented yet"() { | ||
// end::example-a[] | ||
expect: | ||
false | ||
} | ||
|
||
// tag::example-b[] | ||
@PendingFeature(exceptions = [ | ||
UnsupportedOperationException, | ||
IllegalArgumentException | ||
]) | ||
def "I throw one of two exceptions"() { | ||
// end::example-b[] | ||
expect: | ||
throw new IllegalArgumentException() | ||
} | ||
|
||
// tag::example-c[] | ||
@PendingFeature( | ||
exceptions = UnsupportedOperationException, | ||
reason = 'operation not yet supported') | ||
@PendingFeature( | ||
exceptions = IllegalArgumentException, | ||
reason = 'arguments are broken') | ||
@PendingFeatureIf( | ||
value = { os.windows }, | ||
reason = 'Does not yet work on Windows') | ||
def "I have various problems in certain situations"() { | ||
// end::example-c[] | ||
expect: | ||
throw new IllegalArgumentException() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,29 @@ def bar() { | |
} | ||
} | ||
|
||
def "@PendingFeature marks failing feature as skipped even if applied twice"() { | ||
when: | ||
def result = runner.runSpecBody """ | ||
@PendingFeature | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While not "wrong", it is redundant, we should check for redundant annotations, as the user probably intended something different. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The question is, how much logic to stuff in for those redundancy checks and how much to trust the user. |
||
@PendingFeature | ||
def bar() { | ||
expect: false | ||
} | ||
""" | ||
|
||
then: | ||
verifyAll(result) { | ||
testsStartedCount == 1 | ||
testsSucceededCount == 0 | ||
testsFailedCount == 0 | ||
testsSkippedCount == 0 | ||
testsAbortedCount == 1 | ||
testEvents().aborted().assertEventsMatchExactly( | ||
abortedWithReason(message('Feature not yet implemented correctly.')) | ||
) | ||
} | ||
} | ||
|
||
def "@PendingFeature includes reason in exception message"() { | ||
when: | ||
def result = runner.runSpecBody """ | ||
|
@@ -61,6 +84,52 @@ def bar() { | |
} | ||
} | ||
|
||
def "@PendingFeature includes last reason in exception message if applied twice"() { | ||
when: | ||
def result = runner.runSpecBody """ | ||
@PendingFeature(reason='42') | ||
@PendingFeature(reason='4711') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks even more like an error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While there is probably no sensible use-case for this in the wild, the test is just intended to ensure a stable reason being shown in the error message. As for the redundancy-check or whatever, let's continue above. |
||
def bar() { | ||
expect: false | ||
} | ||
""" | ||
|
||
then: | ||
verifyAll(result) { | ||
testsStartedCount == 1 | ||
testsSucceededCount == 0 | ||
testsFailedCount == 0 | ||
testsSkippedCount == 0 | ||
testsAbortedCount == 1 | ||
testEvents().aborted().assertEventsMatchExactly( | ||
abortedWithReason(message('Feature not yet implemented correctly. Reason: 4711')) | ||
) | ||
} | ||
} | ||
|
||
def "@PendingFeature includes reason of matching annotation in exception message if applied twice"() { | ||
when: | ||
def result = runner.runSpecBody """ | ||
@PendingFeature(exceptions=IllegalArgumentException, reason='42') | ||
@PendingFeature(exceptions=IllegalAccessException, reason='4711') | ||
def bar() { | ||
expect: throw new IllegalArgumentException() | ||
} | ||
""" | ||
|
||
then: | ||
verifyAll(result) { | ||
testsStartedCount == 1 | ||
testsSucceededCount == 0 | ||
testsFailedCount == 0 | ||
testsSkippedCount == 0 | ||
testsAbortedCount == 1 | ||
testEvents().aborted().assertEventsMatchExactly( | ||
abortedWithReason(message('Feature not yet implemented correctly. Reason: 42')) | ||
) | ||
} | ||
} | ||
|
||
def "@PendingFeature marks feature that fails with exception as skipped"() { | ||
when: | ||
def result = runner.runSpecBody """ | ||
|
@@ -107,6 +176,30 @@ def bar() { | |
} | ||
} | ||
|
||
def "@PendingFeature rethrows non handled exceptions even if applied twice"() { | ||
when: | ||
def result = runner.runSpecBody """ | ||
@PendingFeature(exceptions=IndexOutOfBoundsException) | ||
@PendingFeature(exceptions=IllegalAccessException) | ||
def bar() { | ||
expect: | ||
throw new IllegalArgumentException() | ||
} | ||
""" | ||
|
||
then: | ||
verifyAll(result) { | ||
testsStartedCount == 1 | ||
testsSucceededCount == 0 | ||
testsFailedCount == 1 | ||
testsSkippedCount == 0 | ||
testsAbortedCount == 0 | ||
testEvents().failed().assertEventsMatchExactly( | ||
finishedWithFailure(instanceOf(IllegalArgumentException)) | ||
) | ||
} | ||
} | ||
|
||
def "@PendingFeature marks passing feature as failed"() { | ||
when: | ||
def result = runner.runSpecBody """ | ||
|
@@ -129,6 +222,29 @@ def bar() { | |
} | ||
} | ||
|
||
def "@PendingFeature marks passing feature as failed even if applied twice"() { | ||
when: | ||
def result = runner.runSpecBody """ | ||
@PendingFeature | ||
@PendingFeature | ||
def bar() { | ||
expect: true | ||
} | ||
""" | ||
|
||
then: | ||
verifyAll(result) { | ||
testsStartedCount == 1 | ||
testsSucceededCount == 0 | ||
testsFailedCount == 1 | ||
testsSkippedCount == 0 | ||
testsAbortedCount == 0 | ||
testEvents().failed().assertEventsMatchExactly( | ||
finishedWithFailure(message('Feature is marked with @PendingFeature but passes unexpectedly')) | ||
) | ||
} | ||
} | ||
|
||
def "@PendingFeature ignores aborted feature"() { | ||
when: | ||
def result = runner.runSpecBody """ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe include an example that has a list of exceptions