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.
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.
Posted by Jonas Bandi on July 02, 2009 at 12:32 PM CEST #
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
Posted by mbien on July 02, 2009 at 01:20 PM 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?
Posted by Ela on July 02, 2009 at 04:53 PM CEST #
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..
Posted by Daniel on July 02, 2009 at 04:55 PM CEST #
I guess, because it is derived from the debug shortcut (F5) :-).
It is nice to know, that so many people are interested in testing :-),
Posted by Adam Bien on July 02, 2009 at 08: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.
Posted by Edward Samson on July 03, 2009 at 03:06 PM CEST #
Thank you for useful information.
Posted by mark benz on August 24, 2009 at 08:22 PM CEST #