bndtools / bnd

Bnd/Bndtools. Tooling to build OSGi bundles including Eclipse, Maven, and Gradle plugins.
https://bndtools.org
Other
531 stars 305 forks source link

Exceptions during test detection are swallowed #5403

Closed reckart closed 1 year ago

reckart commented 2 years ago

Exceptions during test detection are swallowed and may not be visible to the user.

E.g. I found the reason for tests not being able to be discovered in https://github.com/bndtools/bnd/issues/5402 only by setting a breakpoint on org.junit.platform.commons.JUnitException and running the OSGI tests in debug mode. Then I had to traverse the stack trace until I found a helpful exception:

Screenshot 2022-10-20 at 10 25 44

The UnsupportedClassVersionError is retained as the cause in the JUnitException that is passed up to the BND tooling.

Screenshot 2022-10-20 at 10 29 42

It would be great if the root cause could somehow make it to the UI for the developer user to be able to see it.

kriegfrj commented 2 years ago

It would be great if the root cause could somehow make it to the UI for the developer user to be able to see it.

I agree. But there is something about this case which is not as simple as first meets the eye. There already is code in BundleEngine which does its best to catch uncaught exceptions and send them to the GUI:

https://github.com/bndtools/bnd/blob/49f35bc9deba6c49e8c25ee307c89776f1a88231/biz.aQute.tester.junit-platform/src/aQute/tester/bundle/engine/BundleEngine.java#L103-L107

From what I can see, it looks like your UnsupportedClassVersionError is being thrown from outside the scope of the above catch. This means it's within JUnit Platform somewhere - not from within BundleEngine. In other words, it is happening after our code's last chance to catch and report it.

On the other hand, it looks like JUnit Platform is trying to do the right thing with the reporting by registering the JUnitException as a test failure (which the GUI can then display). So maybe if we fix the NPE issue it might take care of itself.

Also, ''it might help''' (if you can) if you could post the stack trace of the UnsupportedClassVersionError itself (the stack trace I can see in the GUI is for the wrapping JUnitException, not for the root cause.

bjhargrave commented 1 year ago

Is this still an issue in Bnd 6.4.0 given it has the fix for #5402?

reckart commented 1 year ago

I don't know. From my perspective, we can close it and if I encounter it again, I'll comment or open a new one.