我正在尝试根据类别运行测试,但似乎不起作用。我有春季启动应用程序
Pom.xml
是
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.17</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
我也定义了类别
package com.in28minutes.springboot.controller;
public interface FastTests {
}
和junit只是为了测试
package com.in28minutes.springboot.controller;
import org.junit.Test;
import org.junit.experimental.categories.Category;
public class B {
@Category({ FastTests.class })
@Test
public void c() {
System.out.println("Hello \n\n\n\n\n");
}
}
但是当我尝试运行maven命令时
mvn test -Dgroups="com.in28minutes.springboot.controller.FastTests"
没有执行任何测试。我假设它应该从类B
执行测试。