在Maven验证阶段跳过特定的测试类

问题描述

我有几个用backend-serverService注释的测试类。 我在Maven SpringBoot项目中使用以下依赖项:

@RunWith

当我运行@ContextConfiguration时,它将执行我所有的测试类。

现在,我有一个特定的测试类,我想在<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> 阶段忽略

我尝试用mvn clean verify对其进行注释,所以最终该类如下:

verify

所以我在@ConditionalOnProperty文件中添加了一个属性:

@RunWith(SpringRunner.class)
@ContextConfiguration(classes = { RestTemplate.class,AvailabilityService.class,VerifyService.class,ConfirmService.class })
@ComponentScan(basePackages = "it.alpitour")
@TestPropertySource("classpath:application-test.properties")
@ConditionalOnProperty("test.api.real.run")
public class ToIgnoreTest {

但是在application-test.properties阶段,测试仍然执行并且未被忽略。

我如何跳过它?

谢谢

修改

我不希望使用test.api.real.run=false ,因为我有时需要手动运行该特定测试。 我只需要在所有其他测试都在运行时就排除那个。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)