renatoathaydes / spock-reports

This project creates a global extension to Spock to create test reports.
Apache License 2.0
273 stars 68 forks source link

reportInfo doesn't work correctly with spock's parallel execution #219

Closed dariuslf closed 2 years ago

dariuslf commented 2 years ago

I've recently tried adding extra info to the reports to note which test data has been used. the reportInfo exnsion function is great. However, things didn't work out when configuring spock to run in parallel, eg.

runner { parallel { enabled true fixed(4) } }

The info traced with reportInfo wasn't necessarily located in the correct feature report! I could get four features of a single spec starting at the same time and the info traced by each landing all together on one of the features.

renatoathaydes commented 2 years ago

Ah parallel builds are being difficult to get right!

This might be a simple fix, I hope... I will have a look at why this would happen.

renatoathaydes commented 2 years ago

The information is collected at SpockReportsSpecificationExtension. Looks like that will be hard to work in parallel builds!

dariuslf commented 2 years ago

Yes, I understand. Maybe you can use the specificationContext property (https://github.com/spockframework/spock/blob/232514b2bf2755968138b52e95fffa98e57764f0/spock-core/src/main/java/org/spockframework/lang/SpecInternals.java#L34) from within your reportInfo extension method to get the name of the currently executing feature. It's marked as @Beta so I guess you can decide whether it's appropriate.

renatoathaydes commented 2 years ago

Problem is now fixed. Thanks @dariuslf for the heads up on specificationContext, that helped a lot!

I had to introduce a breaking change on report templates in order to get this fixed. Please see the commit linked below if anyone has problems with their templates.

dariuslf commented 2 years ago

Just wanted to thank you for this. Looks great!