Hi all,
I've having a problem testing a DataflowVariable with a Spock test.
Consider the following test case:
class Lazy {
def bar(final x) {
return x
}
def foo() {
def closure = { bar('Hello') }
new LazyDataflowVariable(closure) .getVal()
}
}
I want to check that the `bar` method is invoked exactly one time by the
LazyDataflowVariable when the method `foo` is called. The test I'm using is
the following:
class LazyTest extends Spefication {
def 'should invoke bar method' () {
given:
def lazy = Spy(Lazy)
when:
def result = lazy.foo()
then:
1 * lazy.bar('Hello') >> 'Hello'
result == 'Hello'
}
}
However what happens is that is just hangs, because it seems that the
dataflow variable never invokes the initialisation closure.
Any idea what is wrong? or any workaround ?