Adam Bien's Weblog

Thursday Jul 02, 2009

How To Debug Unit Tests In Netbeans 6.7

In Netbeans 6.7 you can invoke, and especially debug unit tests in the following way:

1. From test results:
- Invoke context menu on a given test and select 'Debug'

2. From project
-  Select test file and choose "Debug->Debug Test File" from main menu or press Ctrl_Shift_F6 (on Mac Cmd_Shift_F6)

The way on how test are executed is changed right after 6.5, you may get more insight from http://www.netbeans.org/issues/show_bug.cgi?id=119922

Please also check http://www.netbeans.org/issues/show_bug.cgi?id=158812, to track the recent changes.

Thanks to Alexei Mokeev for providing this information - I was shortly before filing a P1 bug :-). In my opinion the Netbeans 6.5 way was more intuitive.  


[my tweets]  Rss My book: Real World Java EE - Rethinking Best Practices

Kommentare:

I still have issues, that are major showstoppers for me:

- Running single test methods is not easily possible
- Failing JUnit tests in maven projects when run with with 'Test File' and not with 'Test Project'
- Running TestNG tests always delegates to the Maven test goal, nevertheless if I choose 'Run Test Method' or 'Run Test Class'. Which results in all tests beeing run... and Maven wasting time elsewhere.

It might well be that I have overlooked some trick.
But I have to say that both Eclipse and IntelliJ just work out of the box for the above scenarios. I have tried it on exactly the same projects.

See also:
http://blog.jonasbandi.net/2009/07/netbeans-showstopper-running-tests.html

Gesendet von Jonas Bandi am July 02, 2009 at 10:32 AM CEST #

Jonas,
have you filed a bug report? Would like to vote ;)

@adam i customized the NB toolbar (right click) and added test file and run file... found it usefull

Gesendet von mbien am July 02, 2009 at 11:20 AM CEST #

It is all nice and dandy, but why does
context menu for a test file suggest ( correctly ) "CTRL+F6" for running it, but "CTRL+Shift+F5" for debugging it?

Gesendet von Ela am July 02, 2009 at 02:53 PM CEST #

Hi Adam,
thanks for this post. It seems i have not been the only one with this issue.
I am also of the opinion that it was more intuitive in 6.5
But i love the new look and feel and the kenai integration
Hopefully, the jsf/jsp editor opens faster. I haven't had the time to test this..
greetings
Daniel

Gesendet von Daniel am July 02, 2009 at 02:55 PM CEST #

@Ela

I guess, because it is derived from the debug shortcut (F5) :-).

It is nice to know, that so many people are interested in testing :-),

regards,

adam

Gesendet von Adam Bien am July 02, 2009 at 06:06 PM CEST #

Another change from nb6.5: when I try to do this on a maven project, nb6.7 uses its own test runner to run the tests instead of using maven surefire. This caused tests that depended on some surefire plugin configurations to fail.

Gesendet von Edward Samson am July 03, 2009 at 01:06 PM CEST #

Thank you for useful information.

Gesendet von mark benz am August 24, 2009 at 06:22 PM CEST #

Senden Sie einen Kommentar:
  • HTML Syntax: Ausgeschaltet
Interviews/About
My Recent Book
Java One 2009
CommunityOne East N.Y.C
JavaONE 2008 Interview
Search
...the last 150 posts
...the last 10 comments
greenfire.dev.java.net
Links
my.netbeans.org
Visitors
License