Running JUnit tests with Maven under Eclipse

后端 未结 2 2015
一向
一向 2020-12-15 08:16

I just installed the plugin m2e for the first time on Eclipse.

I wrote a simple JUnit (version 4) test. I can run it from Eclipse, but not from the pom.xml (alt-clic

相关标签:
2条回答
  • 2020-12-15 08:58

    Add this to your pom.xml

    <project>
      [...]
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-surefire-plugin</artifactId>
              <version>2.18.1</version>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
      [...]
    </project>
    

    run maven with clean test

    0 讨论(0)
  • 2020-12-15 09:10

    you can run Junit 4 with Maven. You just need the Junit 4 dependency in your pom. You also need the surefire plugin to execute the tests.

    See: http://maven.apache.org/plugins/maven-surefire-plugin/

    Hint: By default surefire looks for files with *Test.java naming to find tests.

    0 讨论(0)
提交回复
热议问题