I just noticed that Spock does not state the conditions if I add an if clause in the wait block, as in
def myTest() { given: a = true expect: if ( a ) { 1 == 2 } else { 1 == 1 } }
The above test will pass because the conditions are not checked. Or the status check is not forwarded using the if statement.
The workaround to this is to add assert inside the if block, i.e. assert 1 == 2.
What interests me, why is this functionality? Is there any other way around this? I suppose this has something to do with the Groovy if statement function, but I don't know the details of the language well enough. Most likely, the if statement returns nothing for the Spock wait block.
source share