thenirajpandey / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

Initialization in setupSpec for a @Shared field defined in trait is overridden #370

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
Pull request: https://github.com/spockframework/spock/pull/42

Original comment by msz...@wp.pl on 14 Jul 2014 at 9:44