netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

fixes evaluation order of stack trace

Open homberghp opened this issue 7 months ago • 0 comments

This version works for ant projects. (Including netbeans projects). This PR closes #8567

This implementation of finding file object+line number reverses the search by starting at the top of the stack and try to find the stack frame that is directly related to the test method.

It reverses the loop running from bottom to top into running from the top stack frame to the bottom one. It effectively tries to find the first stack element that matches the testMethod involved instead of the first element that is NOT in some (testing) framework. For most tests this appears to be the logical choice, in particular in the non-optimal practice of having multiple assert or assert-like statements in one test method.

For NetBeans developers, in particular those working on refactoring related stuff and tests, it is more useful to point to the failing assert or verifyXXX call than in some method inside some method inside the test class or a superclass thereof that generalizes repetitive work in the tests.

In the original the goto source landed me in https://github.com/apache/netbeans/blob/68e420dcd08d0e1a3bb7fc1687dd0722881e9422/java/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java#L405-L418

instead of say line 118 below, which is the more logical line to choose in most cases.

https://github.com/apache/netbeans/blob/68e420dcd08d0e1a3bb7fc1687dd0722881e9422/java/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/InnerToOutterTest.java#L117-L118

This PR solves the problem for both maven and ant projects in a similar way.

homberghp avatar Jun 07 '25 14:06 homberghp

solves #8567

homberghp avatar Jun 13 '25 10:06 homberghp

@homberghp This currently fails to build from source. This import looks broken: jdk.internal.net.http.common.Log. Please fix, squash all changes and rebase onto current master.

matthiasblaesing avatar Nov 23 '25 15:11 matthiasblaesing