I am new to installing and noticed the installation: the step in the specification is localized for this particular test. How can I share the settings for these devices, similar to the traditional junit approach?
Thank you!
def "setup with spock"() { setup: def message = new FooMessage() def sut = new FooProcessor() def builder = Mock(FooBuilder) sut.setBuilder(builder) when: builder.buildFooUsing(_) >> {"bar"} def result = sut.process(message) then: assert result == "bar" }
You should use setupSpec () or see the @Shared annotation if you want to share one object in tests
From the Spock documentation
1.3.4 Exchange of objects between iterations
To split an object between iterations, it must be stored in the @Shared or static field.
. @Shared : block.
, . . , , , spec, . .