我想使用Maven的Spring Boot测试集成功能。当我运行的下一个命令我看到它不工作如我所料:Maven-failsafe-plugin:skipTests配置不适用于Spring Boot 1.4集成测试
mvn clean install -DskipIntegrationTests=true
它开始运行集成测试,但应该跳过他们。 我的问题是:
- 我该如何控制集成测试执行与maven?
- 我真的需要一个maven-failsafe插件吗?
注:我使用的弹簧引导1.4.0.RELEASE 我POM:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<skipTests>${skipIntegrationTests}</skipTests>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
我的集成测试:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("development")
@SqlGroup({
@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:beforeTestRun.sql"),
@Sql(executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD, scripts = "classpath:afterTestRun.sql")
})
public class AdminTest {
@Autowired
private TestRestTemplate restTemplate;
@Test
public void get_all_admins() {
//TODO: code here
}
}
与正常单元测试相比,您如何将该测试识别为“集成测试”? –
我不认同,可能是我错过了一些maven插件配置 – Dimon