【问题标题】:Run unit tests and IT tests separately while launching pre-integration and post-integration在启动预集成和后集成时分别运行单元测试和 IT 测试
【发布时间】:2019-08-29 14:04:17
【问题描述】:

我希望能够分别运行单元测试和集成测试。我已经尝试使用不同的故障安全配置并验证哪些确实有效,但是当使用故障安全或在命令行中验证时(mvn failsafe:test、mvn surefire:verify 等),它不会启动我的 pre-集成测试所需的集成和集成后阶段。

这是我的 POM:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
    <mainClass>com.nulogix.billing.App</mainClass>
    </configuration>
    <executions>
        <execution>
            <id>pre-integration-test</id>
            <goals>
                <goal>start</goal>
            </goals>
        </execution>
        <execution>
            <id>post-integration-test</id>
            <goals>
                <goal>stop</goal>
            </goals>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.18.1</version>
    <executions>
        <execution>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M3</version>
    <configuration>
        <skipTests>false</skipTests>
    </configuration>
</plugin>

【问题讨论】:

  • 使用 Spring Boot 运行集成测试需要什么样的预集成测试部分?

标签: java maven unit-testing spring-boot integration-testing


【解决方案1】:

您不能单独运行一个阶段或一堆阶段。

您可以在命令行上进行所有插件调用,或者从开始到集成后运行整个构建。

另一方面,如果您的主要目标是在构建期间跳过某些插件,您可以通过 skip 参数或配置文件来实现。

【讨论】:

    猜你喜欢
    • 2011-12-25
    • 1970-01-01
    • 1970-01-01
    • 2012-05-05
    • 1970-01-01
    • 2011-02-06
    • 2016-01-23
    • 2016-10-03
    • 1970-01-01
    相关资源
    最近更新 更多