I've been using Spock for a relatively long time. But this is puzzling me.
With this then
block:
then:
log.info( "in the then block")
def outString = outBuffer.toString( 'UTF-8' )
println( "outString |$outString|" )
outBuffer.toString( 'UTF-8' ) ==~ /(?is).*see log.*/
// detect that something has been logged
// 1 * spyIM.logToInfo( _ ) >> {
// assert it[ 0 ] ==~ /(?is).*indexInfo file failed to be created.*/
// }
... the message gets logged, outstring
gets printed to stdout
, and the pattern match is executed (and is currently failing...).
If I uncomment the last 3 lines, only that command is executed. The previous lines in the then
block are completely ignored... unless the assert
passes (returns true
): then they are all executed.
Are then
blocks executed in more than one pass? With mock methods being examined in the first pass? I can't think of another explanation. Is this documented somewhere?
NB yes, it occurs to me to ditch the use of assert
and to try to find another way of testing the parameter passed to logToInfo
.
Aucun commentaire:
Enregistrer un commentaire