This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 213935 - [72cat] Not able to navigate to the cause of a JUnit failure for Maven Java SE project
Summary: [72cat] Not able to navigate to the cause of a JUnit failure for Maven Java S...
Status: VERIFIED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.2
Hardware: PC Windows 7 x64
: P3 normal (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-11 07:33 UTC by crazyjavahacking
Modified: 2012-09-11 20:22 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Maven project to test (35.47 KB, application/octet-stream)
2012-06-11 10:18 UTC, crazyjavahacking
Details

Note You need to log in before you can comment on or make changes to this bug.
Description crazyjavahacking 2012-06-11 07:33:50 UTC
According to the Unit testing TS (http://wiki.netbeans.org/TS_72_UnitTesting#Test_suite:_Different_project_types), it should be able to navigate to the cause of failed JUnit test.

This works for And based Java SE projects, but does not work for Maven based Java SE projects.

For And Java SE projects, I see the node e.g. "expected: <false> but was: <true>" (and below junit.framework.AssertionFailedError) and after clicking on any node representing stack trace and selecting Go To Source, the cursor will be placed on the line with failing assertion.

For Maven Java SE projects, I see the node e.g. "expected: <0.0> but was: <NaN>" (and below java.lang.AssertionError) and after clicking on any node representing the stack trace (excluding those two mentioned nodes resulting in doing nothing), the curson will be placed in the source code of the JUnit framework method.

Practically speaking it behaved differently, but more importantly I am not able to go directly to the assertion that cause the test to fail in Maven Java SE project.


NetBeans Dev 201206100001, Java 6u32 32bit
Comment 1 Theofanis Oikonomou 2012-06-11 09:59:57 UTC
I am sorry but I cannot reproduce in NetBeans IDE Dev (Build 20120611-8da0aa8bc2a9)

I tested it with ant and maven sample project with sample test classes that fail and i was able to navigate to the correct line by right clicking on the stack trace in the results window and selecting "Go to source"

Please reopen if it happens again giving exact steps to reproduce. Thank you
Comment 2 crazyjavahacking 2012-06-11 10:18:13 UTC
Created attachment 120652 [details]
Maven project to test

To reproduce:

1.) Test attached project.
2.) In Test Results window expand teststorun.StatementsTest node and then expand testRegexpChecker method
=> I see the following lines:
  * expected: <false> but was: <true>
  * java.lang.AssertionError

3.) Execute 'Go To Source' action on mentioned nodes
=> in my case nothing happens.
Comment 3 crazyjavahacking 2012-06-11 10:19:08 UTC
With steps to reproduce in previous comment
Comment 4 Theofanis Oikonomou 2012-06-11 11:09:37 UTC
Yes, I can now reproduce. If you create the tests with JUnit 3 though the issue is not visible. This action is handled by maven.junit so reassigning. Sorry if this is not the correct component.
Comment 5 Milos Kleint 2012-06-11 12:38:41 UTC
I cannot reproduce myself in latest dev build on macosx. Both the node coming from test file and suite file are clickable and lead to the appropriate section of the test file.. 

theofanis: have you tested with the attached project?
Comment 6 Milos Kleint 2012-06-14 12:48:59 UTC
The difference between junit 3.x and junit 4.x test execution is that in 4.x the surefire executor classes/methods appear in the stacktraces while in 3.x they don't. The current algo for getting the place in test is to get the first frame in the stack and go there. in 3.x it's the actual test, in 4.x it's a maven class that isn't found in sources and skipped.
Comment 7 Milos Kleint 2012-06-15 13:03:39 UTC
http://hg.netbeans.org/core-main/rev/0d86867fc127

lines that match the  " at package.ClassName.methodName(ClassName.java:39)" pattern and are found, are opened. If not found, nothing happens. Lines that don't match that pattern eg. "java.lang.AssertionError: The test case is a prototype.", are redirected to the testcase linenumber that triggered the failure. The algorithm is to go from root of the stacktrace up and once the test file line number is found, use it. Previously we've take the first frame in the stacktrace, but that doesn't work in cases like junit4 where internal surefire frames are visible.
Comment 8 crazyjavahacking 2012-06-15 13:31:18 UTC
This is very useful feature, thanks for fixing from Unit Testing tribe.

Any chance to be integrated as 72_HR_FIX_CANDIDATE?
Comment 9 Milos Kleint 2012-06-15 13:44:24 UTC
musilt2, mmirilovic: IMHO doesn't match the criteria for a showstopper for 7.2. Disagree? Is there a way to mark as candidate for a bugfix release?
Comment 10 Tomas Danek 2012-06-15 14:00:13 UTC
I'd vote for '72patch_candidate' (assuming there will be any). Mariane?
Comment 11 Quality Engineering 2012-06-16 06:06:37 UTC
Integrated into 'main-golden', will be available in build *201206160001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/0d86867fc127
User: Milos Kleint <mkleint@netbeans.org>
Log: #213935 when appropriate match for current stack line is not found, iterate the stack frames from bottom up and find the linenumber of the testscase and jump there. That's useful for cases when triggering "go to source" on the actual failure texts, rather than the call stacks.
Comment 12 Milos Kleint 2012-08-03 11:25:30 UTC
http://hg.netbeans.org/releases/rev/2b17d77280dc
Comment 13 Quality Engineering 2012-09-01 11:04:16 UTC
Integrated into 'releases', will be available in build *201209010822* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/2b17d77280dc
User: Milos Kleint <mkleint@netbeans.org>
Log: #213935 transplant to release72 branch
Comment 14 Tomas Danek 2012-09-07 14:24:17 UTC
cannot reproduce on attached project, navigation to source works now in 7.2patch1 - verified.