Skip to content

Commit 3afd8b4

Browse files
committed
Reproducer for spockframework#2087
1 parent 792e592 commit 3afd8b4

File tree

1 file changed

+78
-0
lines changed
  • spock-specs/src/test/groovy/org/spockframework/smoke/parameterization

1 file changed

+78
-0
lines changed

spock-specs/src/test/groovy/org/spockframework/smoke/parameterization/DataTables.groovy

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,84 @@ i != 6
400400
result.testsSucceededCount == 6
401401
}
402402
403+
@Issue("https://github.com/spockframework/spock/issues/2087")
404+
def "filter block supports data variables"() {
405+
when:
406+
def result = runner.runFeatureBody '''
407+
expect:
408+
i != 2
409+
410+
where:
411+
i << (1..2)
412+
b = 42
413+
414+
filter:
415+
i != 2
416+
b == 42
417+
'''
418+
419+
then:
420+
result.testsAbortedCount == 0
421+
result.testsFailedCount == 0
422+
result.testsSkippedCount == 0
423+
result.testsStartedCount == 2
424+
result.testsSucceededCount == 2
425+
}
426+
427+
@Issue("https://github.com/spockframework/spock/issues/2087")
428+
def "filter block supports shared fields"() {
429+
when:
430+
def result = runner.runSpecBody '''
431+
@Shared
432+
def b = 42
433+
434+
def "a feature"() {
435+
expect:
436+
i != 2
437+
438+
where:
439+
i << (1..2)
440+
441+
filter:
442+
i != 2
443+
b == 42
444+
}
445+
'''
446+
447+
then:
448+
result.testsAbortedCount == 0
449+
result.testsFailedCount == 0
450+
result.testsSkippedCount == 0
451+
result.testsStartedCount == 2
452+
result.testsSucceededCount == 2
453+
}
454+
455+
def "filter block supports static fields"() {
456+
when:
457+
def result = runner.runSpecBody '''
458+
static b = 42
459+
460+
def "a feature"() {
461+
expect:
462+
i != 2
463+
464+
where:
465+
i << (1..2)
466+
467+
filter:
468+
i != 2
469+
b == 42
470+
}
471+
'''
472+
473+
then:
474+
result.testsAbortedCount == 0
475+
result.testsFailedCount == 0
476+
result.testsSkippedCount == 0
477+
result.testsStartedCount == 2
478+
result.testsSucceededCount == 2
479+
}
480+
403481
def "filter block can not exclude all iterations"() {
404482
when:
405483
runner.runFeatureBody '''

0 commit comments

Comments
 (0)