Java 在maven验证阶段跳过特定的测试类
我有几个用Java 在maven验证阶段跳过特定的测试类,java,spring-boot,maven,junit,Java,Spring Boot,Maven,Junit,我有几个用@RunWith和@ContextConfiguration注释的测试类。 我在maven SpringBoot项目中使用以下依赖项: <dependency> <groupId>org.springframework.batch</groupId> <artifactId>spring-batch-test</artifactId> <scope>test</scope> </dep
@RunWith
和@ContextConfiguration
注释的测试类。
我在maven SpringBoot项目中使用以下依赖项:
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
因此,我在我的应用程序测试.properties
文件中添加了一个属性:
test.api.real.run=false
但在verify
阶段,测试仍会执行,不会被忽略
我怎么能跳过它
谢谢
编辑:
我不喜欢使用@Ignore
,因为我需要在某些时候手动运行特定的测试。
我只需要在所有其他测试运行时排除该选项。如果使用Junit 4,则可以在测试类上使用注释
@ignore
,否则可以使用如下命令:
mvn -Dtest=\!YourTest* install
但我认为,既然您使用的是springboot而不是spring,那么更好的答案应该是:谢谢,但我无法编辑用于运行测试的命令,我更愿意在这种情况下通过代码工作case@Briston12是的,我想,我已经更新了答案。我还没有在springboot中尝试过这个。再次感谢,我考虑过忽略
@Ignore
,但在某个时候我需要手动运行该测试,所以我不能像那样完全忽略它好吧,太好了,@IfProfileValue
成功了!感谢您发布该答案,根据命名模式命名测试,如单元测试*Test.java
,以及集成测试,如*IT.java
。。。
mvn -Dtest=\!YourTest* install