I have a maven project in netbeans 6.9.1, in there a junit 4.4 test class.
In netbeans context menu I can “clean and build” my project and in output I can see, that my test class was found and run by surefire.
Now I choose from context menu “debug test file”, in output it goes like
— maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ < project-name> —
Compiling 2 source files to < project-path>\target\test-classes
— maven-surefire-plugin:2.7.2:test (default-cli) @ < project-name> —
Surefire report directory: < project-path>\target\surefire-reports
T E S T S
There are no tests to run.
What I’ve checked so far:
-
Build project finds test files, but nonetheless < testSourceDirectory> is there and correct
-
There is only one junit – 4.4 in *.pom dependencies
-
class file itself looks like
import junit.framework.TestCase;
import org.junit.Test;
public class SomeTest extends TestCase
{
@Test
public void testFoo() throws Exception { /—/}
} -
netbeans action description for debug looks like
execute goal: test-compile surefire:test
set properties :
jpda.listen=true
maven.surefire.debug=-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}
jpda.stopclass=${packageClassName}
failIfNoTests=false // this is my addition, w/o it still failed
forkMode=once
test=${className} -
there is no surefire plugin section anywhere in project *.pom files
This isn’t really a netbeans question.
You’ve defined JUnit 3 tests, but you’re trying to run them with a JUnit 4 runner. Surefire uses the following rule to determine which runner to use (from maven-surefire-plugin Junit)
You’ve got junit 4.4 in your project, so it’s using junit4. Since you’ve only got 2 test classes, the best option is to redefine your tests to be JUnit 4 tests. Remove the extends TestCase, add @Test/@Before/@After annotations to your tests, and remove the JUnit 3 stuff altogether.
For more information on doing the migration, see Best way to automagically migrate tests from JUnit 3 to JUnit 4?