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

Issue with error reporting during spec setup / cleanup #218

Closed dariuslf closed 2 years ago

dariuslf commented 2 years ago

Hi @renatoathaydes, you helped out with this before (#212).

But your commits to resolve #215 seem to have reintroduced an issue.

https://github.com/renatoathaydes/spock-reports/blob/master/src/main/groovy/com/athaydes/spockframework/report/SpockReportExtension.groovy#L195

This line now dereferences errorInfo.method.feature.spec causing an NRE if the method is not part of a feature.

https://github.com/renatoathaydes/spock-reports/blob/master/src/main/groovy/com/athaydes/spockframework/report/SpockReportExtension.groovy#L204

This line already dereferences errorInfo.method?.kind safely and I would propose updating line 195 to do likewise, ie. errorInfo.method?.feature?.spec.

Thanks for your effort with this project!

renatoathaydes commented 2 years ago

Sorry about that.

I've fixed it now in the dev branch. I made sure all access to errorInfo.method is null-safe, but I noticed mosts accesses in Spock itself don't check that for null.

Please let me know if you can try to build locally and confirm the bug fix.

There's another bug fix waiting for release (https://github.com/renatoathaydes/spock-reports/issues/217) so I want to make a release as soon as possible.

dariuslf commented 2 years ago

Great, that seems to have done the trick. Looking forward to a release!

renatoathaydes commented 2 years ago

Released fix in 2.1.1-groovy-3.0.