Closed
Description
Hey,
We've just tried out latest Spock 2.0-M4
, we're getting the following exception:
Task :compileTestGroovy
startup failed:
NestedAssertTest.groovy: -1: The current scope already contains a variable of the name $spock_errorCollector
@ line -1, column -1.
NestedAssertTest.groovy: -1: The current scope already contains a variable of the name $spock_valueRecorder
@ line -1, column -1.
2 errors
The cause seems to be that nested assert
s seem to generate conflicting code, irrespective of their level or other previously generated ones (can be "".with {}
or whatever closure):
def nestedAssert() {
tap {
assert 0
tap { assert 0 }
}
}
The following reproducer can be used by running ./gradlew build
:
https://github.com/paplorinc/spock-bug/blob/master/src/test/groovy/NestedAssertTest.groovy