如何运行TestMaven?
我对maven任务中的调用单元测试有问题。My如何运行TestMaven?,maven,intellij-idea,Maven,Intellij Idea,我对maven任务中的调用单元测试有问题。Mypom.xml: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM
pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>FizzBuzzTDDKata</groupId>
<artifactId>FizzBuzzTDDKata</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit/junit5-engine -->
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit5-engine</artifactId>
<version>5.0.0-ALPHA</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
我正在使用Intellij IDEA 2016.2.5 Ultimate,每个maven任务都作为Intellij中的运行配置运行。我做错了什么?我是否应该向
pom.xml
添加一些其他依赖项、构建 首先,您需要添加
<build>
<plugins>
...
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.0-M4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
...
. 然后你必须定义一个测试引擎,链接中也有描述
<build>
<plugins>
...
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.0-M4</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.0.0-M4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
...
maven surefire插件
2.19
org.junit.platform
junit平台surefire提供程序
1.0.0-M4
org.junit.jupiter
朱尼特木星发动机
5.0.0-M4
...
...
org.junit.jupiter
JUnitJupiter api
5.0.0-M4
测试
这应该是全部。不幸的是,这对我也没有帮助。我知道的一个常见问题是,测试类没有命名为Test.java或Test.java。您如何命名它?测试类的名称为FizzBuzzTest.java
。我可以访问此项目吗?我更容易看到这个问题。否则,我会问你很多问题。我删除了那个项目,开始使用Junit4,这可能是我本地软件的一些问题。
<build>
<plugins>
...
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.0-M4</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.0.0-M4</version>
</dependency>
</dependencies>
</plugin>
</plugins>