Alexey Kuznetsov
Alexey Kuznetsov

Reputation: 55

Debugging maven tests with netbeans 6.9.1?

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:

Upvotes: 4

Views: 1114

Answers (1)

Matthew Farwell
Matthew Farwell

Reputation: 61705

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)

if the JUnit version in the project >= 4.7 and the parallel attribute has ANY value
    use junit47 provider
if JUnit >= 4.0 is present
    use junit4 provider
else
    use junit3.8.1

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?

Upvotes: 3

Related Questions