Description
Apache NetBeans version
Apache NetBeans 26
What happened
When running JUnit tests within NetBeans, depending on the test, the UI jumps to the wrong line when you select 'go to source' for a failed test.
To recreate this situation, do the following.
Language / Project Type / NetBeans Component
No response
How to reproduce
Build NetBeans.
To make a test fail, modify one of the tests in RenameRecordTest.java for instance the first by
changing the expected class name 'Use' to read 'Ase'. This will make the test fail.
Test the file (or the single method) with the test results window open.
After some time the UI will report that the the test failed.
On the failing test right-click and select 'go to source'.
In this case, you will land in the file ReforctoringTestBase.java at line 411.
This is not the source of the test case.
The file we land in is not really relevant, but it is the wrong location.
The stack trace is evaluated by NetBeans to find the location of the failing test, typically and assert.
It does this 'bottom up' and tries to skip the stack frames that are not part of the user tests.
It does this by assuming that files that share the same parent (directory) as the test file, is the one to find.
In my opinion, a better approach would be to evaluate the stack trace top to bottom, trying to find the
fully qualified name of the test method, and to that method extract the line number.
Did this work correctly in an earlier version?
No / Don't know
Operating System
ubuntu 24.04
JDK
jdk 17
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
This issue can be resolved by changing the order of stack evaluation from 'bottom to top' to 'top to bottom´.
Are you willing to submit a pull request?
Yes