JeffFaer / junit5-extensions

Personal repository for JUnit 5 extensions
MIT License
40 stars 8 forks source link

Guice extension swallows module loading errors #9

Open nayeemzen opened 2 years ago

nayeemzen commented 2 years ago

The Guice Junit5 extension swallows any module loading errors (e.g errors that could happen during object creation), which leads to a generic error

No ParameterResolver registered for parameter

This makes the actual error cause hard to debug, since we'll have to dig into what's causing the error, most likely with a breakpoint here.

Should it be swallowing ConfigurationException? Might be better to let it fail eagerly since something clearly went wrong trying to load the Guice module, or add some logs so its immediately obvious what the error is.

JeffFaer commented 2 years ago

Admittedly, I haven't really been using this project, and I haven't dabbled much with Java modules, so I'm not too familiar with them.

Do module loading errors typically show up as ConfigurationExceptions? I would've thought they'd show up as ExceptionInInitializerErrors (or something similar), which would get wrapped into a ProvisionException.

I think I agree with you that swallowing ConfigurationExceptions seems like a bad idea (ideally, we should just fix the module configuration mistake instead of allowing the test to try and run anyway), and I don't have any notes on what I was thinking back then either :)

If you think this would stop us from swallowing module loading errors, I'd be happy to approve a PR that stops us from swallowing ConfigurationExceptions.