Debugging maven tests with netbeans 6.9.1?

I have a maven project in netbeans 6.9.1, there is a junit 4.4 test class there.

In the netbeans context menu, I can β€œclean and build” my project, and in the output I see that my test class was found and launched using surefire.

Now I select "debug test file" from the context menu, on the output it looks like

--- maven-compiler-plugin: 2.3.2: testCompile (default-testCompile) @ <project name> --- Compilation of 2 source files into <Project path> \ target \ test classes

--- maven-surefire-plugin: 2.7.2: test (default-cli) @ <project name> --- Surefire report directory: <Project path> \ target \ Surefire reports


TESTS


There are no tests to run.

What I checked so far:

  • The build project finds the test files, but nevertheless <testSourceDirectory> is and is correct

  • There is only one junit - 4.4 in * .pom dependencies

  • The class file looks like

    import junit.framework.TestCase;

    import org.junit.Test;

    public class SomeTest extends TestCase {@ Verification public void testFoo () throws Exception {/ --- /}}

  • The netbeans debug action description looks like

    fulfill the 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 mine addition, without it still failed forkMode = once Test = $ {class name}

  • there is no plugfire plugin in the * .pom project file

+4
source share
1 answer

This is not a netbeans question.

You have defined JUnit 3 tests, but you are 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 have junit 4.4 in your project, so it uses junit4. Since you only have 2 test classes, the best option is to override your JUnit 4 tests. Remove the TestCase extension, add @ Test / @ Before / @ After annotating your tests, and generally remove the JUnit 3 stuff.

For more information on performing migration, see Best way to automatically migrate tests from JUnit 3 to JUnit 4?

+3
source

Source: https://habr.com/ru/post/1383864/


All Articles