I've been playing with Spock and traits mix and I spotted an issue with @Shared
field declared in a trait. Following code fails:
class SharedTraitUsage extends Specification implements MySharedTrait {
def "should not restore inline assigned value on shared field defined in trait before every test"() {
expect:
sharedValue == 11
}
}
trait MySharedTrait {
@Shared
int sharedValue = 12
def setupSpec() {
sharedValue = 11
}
with the error:
Condition not satisfied:
sharedValue == 11
| |
12 false
I started debugging AST transformations using `EmbeddedSpecification`, but I
wasn't able to find a clear way how to "fix" it. More details and a broken test
I will put as a pull request.
Original issue reported on code.google.com by msz...@wp.pl on 14 Jul 2014 at 9:32
class SharedTraitUsage extends Specification implements MySharedTrait { def "should not restore inline assigned value on shared field defined in trait before every test"() { expect: sharedValue == 11 } }
trait MySharedTrait { @Shared int sharedValue = 12
def setupSpec() { sharedValue = 11 }
Condition not satisfied:
sharedValue == 11 | | 12 false
Original issue reported on code.google.com by
msz...@wp.pl
on 14 Jul 2014 at 9:32