Skip to content

Commit

Permalink
Allow multiple @RepeatUntilFailure annotations ... (#1912)
Browse files Browse the repository at this point in the history
within the same specification.

Currently, if you do that, both skip the other one.
But sometimes, you want to repeat multiple features in a specification,
especially when trying to reproduce flaky race-condition tests.
  • Loading branch information
Vampire committed Mar 10, 2024
1 parent 5c6911e commit 8fc1769
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public void visitFeatureAnnotation(RepeatUntilFailure annotation, FeatureInfo fe
if (annotation.ignoreRest()) {
feature.getSpec().getBottomSpec().getAllFeatures()
.stream()
.filter(f -> f != feature)
.forEach(f -> f.skip("Focussed test run with @RepeatUntilFailure for a single feature."));
.filter(f -> (f != feature) && (f.getFeatureMethod().getAnnotation(RepeatUntilFailure.class) == null))
.forEach(f -> f.skip("Focussed test run with @RepeatUntilFailure."));
}

feature.setForceParameterized(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ class RepeatUntilFailureExtensionSpec extends EmbeddedSpecification {
result.testsFailedCount == 0
}

def "skips other tests in the same class"() {
def "skips other tests in the same class that do not have the same annotation too"() {
when:
def result = runner.runSpecBody """
def "other test 1"() {
expect:
true
}
@RepeatUntilFailure(maxAttempts = 1)
def "other test 2"() {
expect:
true
Expand All @@ -67,10 +68,10 @@ class RepeatUntilFailureExtensionSpec extends EmbeddedSpecification {
"""

then:
result.testsStartedCount == 1 + 1
result.testsSucceededCount == 1 + 1
result.testsStartedCount == 2 + 2
result.testsSucceededCount == 2 + 2
result.testsFailedCount == 0
result.testsSkippedCount == 3
result.testsSkippedCount == 2
}


Expand Down

0 comments on commit 8fc1769

Please sign in to comment.