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 216334

Summary: Patch for: Double-click on a failing testcase method should open the line with the failing assertation within the testfile
Product: java Reporter: markiewb
Component: JUnitAssignee: Theofanis Oikonomou <theofanis>
Status: RESOLVED FIXED    
Severity: normal CC: anebuzelsky, markiewb, psomol
Priority: P3 Keywords: PATCH_AVAILABLE, PLAN
Version: 7.2   
Hardware: PC   
OS: Windows 7   
See Also: http://netbeans.org/bugzilla/show_bug.cgi?id=163986
http://netbeans.org/bugzilla/show_bug.cgi?id=213935
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: Screenshot with sample
Proposed patch for junit-module / working patch based on main
Proposed patch for junit- and maven.junit-module
Sample projects for testing
patching junit, maven.junit and testng
ant/maven junit/testng projects

Description markiewb 2012-08-02 20:51:03 UTC
Created attachment 122694 [details]
Screenshot with sample

When i double click on a junit test failure in the "test result" window then the test source is opened at

ACTUAL: the incorrect line, at the line of @Test
EXPECTED: the correct line, where the fail/assertEquals/assertTrue... failed

See screenshot to see what i expect.

It seemed to worked previously as being fixed in http://netbeans.org/bugzilla/show_bug.cgi?id=163986.

-------
Product Version: NetBeans IDE 7.2 (Build 201207171143)
Java: 1.6.0_30; Java HotSpot(TM) 64-Bit Server VM 20.5-b03
System: Windows 7 version 6.1 running on amd64; Cp1252; de_DE (nb)
Comment 1 markiewb 2012-08-27 22:44:54 UTC
Error is caused by #163986
Comment 2 markiewb 2012-08-27 23:00:25 UTC
Created attachment 123631 [details]
Proposed patch for junit-module / working patch based on main
Comment 3 Theofanis Oikonomou 2012-09-03 09:56:33 UTC
If you double-click on the "testAdd Failed:..." node then you should jump to the start of the test method (line 42). On the other hand if you double-click on the "at de.foo. ... .java:52" node then you should jump to the cause of the failure at line 52.

This is the expected behaviour and since it seems to be the case for you I am closing the bug.
Comment 4 markiewb 2012-09-03 19:44:29 UTC
(In reply to comment #3)
> 
> This is the expected behaviour and since it seems to be the case for you I am
> closing the bug.
Yes, it is the current behaviour i described. BUT not the requested - more useful - one.

I try to explain in more detail.

When tests fail then the result list looks like 

+ testA successful
+ testB failed: expected 5 but was 8
+ testC failed: expected true but was false
+ testD successful

When i double-click at the node "testB failed: ..."  then 

ACTUAL: it jumps to the start of the test-method
EXPECTED: it jumps to the cause of the failure (where the assertion failure "5 but was 8" comes from and that is the line i want to start my "why does the test fails investigation")
Comment 5 Theofanis Oikonomou 2012-09-04 07:33:17 UTC
I understand what you are saying. I am not sure though if what you are proposing as the expected behaviour is the way to go. Petr any comments on this? Anyway, I believe this is not a defect. Thank you
Comment 6 markiewb 2012-11-02 23:24:48 UTC
Created attachment 127049 [details]
Proposed patch for junit- and maven.junit-module

I rewrote the patch. Please review!

Details:
* When doubleclicking at a failed MethodNode then the stracktrace-analyse-logic (from http://netbeans.org/bugzilla/show_bug.cgi?id=213935) is used to open the correct line (new behaviour).
* When doubleclicking at a passed MethodNode then the line of the testMethod will be focused (works as before).
* junit and maven.junit have to be patched (TODO: support testng)

In the next commit I will attach two sample projects with JUnit3+4 testcases (JavaApp and MavenJavaApp) so you can easily test the behaviour manually.
Comment 7 markiewb 2012-11-02 23:28:24 UTC
Created attachment 127050 [details]
Sample projects for testing
Comment 8 Theofanis Oikonomou 2013-02-01 14:39:50 UTC
Created attachment 130936 [details]
patching junit, maven.junit and testng
Comment 9 Theofanis Oikonomou 2013-02-01 14:42:48 UTC
Created attachment 130937 [details]
ant/maven junit/testng projects

I think the patch from comment 8 is much simpler. Please apply the proposed patch and verify that it works as expected for you using the supplied projects. Thank you
Comment 10 markiewb 2013-02-03 16:50:53 UTC
(In reply to comment #9)
> Created attachment 130937 [details]
> ant/maven junit/testng projects
> 
> I think the patch from comment 8 is much simpler. Please apply the proposed
> patch and verify that it works as expected for you using the supplied projects.
> Thank you

You are right. Your patch looks easier AND works as expected! Thanks.
Comment 11 Theofanis Oikonomou 2013-02-11 15:00:15 UTC
Changeset: 2afa9a1fc443
Author:    Theofanis Oikonomou <theofanis@netbeans.org>
Date:      2013-02-11 15:57
Message:   
Issue #216334 - Patch for: Double-click on a failing testcase method should open the line with the failing assertation within the testfile
Comment 12 Quality Engineering 2013-02-13 01:53:40 UTC
Integrated into 'main-golden', will be available in build *201302122300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/2afa9a1fc443
User: Theofanis Oikonomou <theofanis@netbeans.org>
Log: Issue #216334 - Patch for: Double-click on a failing testcase method should open the line with the failing assertation within the testfile