Testing a method instead of testing a whole file in Netbeans w/ JUnit

In NetBeans 7.1, open the unit test file, right click within the specific unit test and select "Run Focused Test."


UPDATE: NetBeans supports this (e.g. see NetBeans 6.8). Just right click the passed or failed test and then click 'Run Again' or 'Debug'. Or right click in the editor and click Run/Debug focused test.

Old:

To my knowledge this is not possible. And maybe the NetBeans-guys had in mind that always all tests should pass for one unit. I know that tools should not limit the developers, but If one method takes too long - maybe you should consider a separate integration test?

Also take a look at this post. (BTW: in maven projects running tests of a unit is possible ...)


Netbeans 7.1 "Run Focused Test" isn't working with my build, so I'm using use a test group to mark the tests I want to run.

@Test(groups={"DEBUG"})

You can configure Netbeans to run these tests by adding -Dgroups=DEBUG to your "Debug Test File" action in the project properties.

Note: these are TestNG methods run with maven/surefire.