Closed ArkiMargust closed 1 year ago
I've tested with @IgnoreIf and it's the same issue. With @Ignore the Code blocks are shown.
I experience the same issue where @Ignore and @IgnoreIf don't have code! This even happens when using custom templates (like this json template I wrote for example).
Also there seems to be a related ~bug where sometimes there is "----" instead of the actual (empty) block text:
"blocks":[
{"kind":"given","text":"----","code":[]},
{"kind":"expect","text":"----","code":[]},
{"kind":"when","text":"----","code":[]},
{"kind":"then","text":"----","code":[]},
{"kind":"when","text":"----","code":[]},
{"kind":"then","text":"----","code":[]},
{"kind":"when","text":"----","code":[]},
{"kind":"then","text":"----","code":[]},
{"kind":"where","text":"----","code":[]}
],
This seems to be related to this source code I found in report/template/TemplateReportCreator.groovy
// as we don't have the AST, we need to use the old way to get the block text from Spock's API
feature.blocks.collect { BlockInfo block ->
List<String> blockTexts = block.texts
if ( !Utils.isEmptyOrContainsOnlyEmptyStrings( blockTexts ) ) {
int index = 0
blockTexts.collect { blockText ->
if ( iteration ) {
blockText = stringProcessor.process( blockText, feature.dataVariables, iteration )
}
[ kind : Utils.block2String[ ( index++ ) == 0 ? block.kind : 'and' ],
text : blockText,
sourceCode: emptyList() ]
}
} else if ( !hideEmptyBlocks ) {
[ [ kind : Utils.block2String[ block.kind ],
text : '----',
sourceCode: emptyList() ] ]
} else {
[ [ : ] ]
}
}.flatten().findAll { Map item -> !item.isEmpty() }
}
I have the feeling that this might be a Spock bug, does Spock maybe not record this kind of data if features are ignored?
I forked and fixed it by preventing the AST traversal of annotations, + added a unit test. I let the forked and modified version run over the 1200+ tests in https://github.com/Gleethos/neureka and it worked perfectly.
Thanks for the PR @Gleethos . I will release a fix as soon as possible. Sorry the delay.
I am glad my PR helps! Thank you for creating and maintaining this powerful project @renatoathaydes !
Sorry the delay. Release on versions 2.4.0-groovy-4.0
and 2.3.2-groovy-4.0
.
Dear @renatoathaydes,
Hoping that you could look into this and for it to be an easy fix.
To add, regardless whether the condition for the @Requires Annotation is met (Feature is executed/ignored), the code blocks are not shown in the report.
Thank you!