简体   繁体   English

在启动集成前和集成后分别运行单元测试和IT测试

[英]Run unit tests and IT tests separately while launching pre-integration and post-integration

I want to be able to run unit tests and integration tests separately. 我希望能够分别运行单元测试和集成测试。 I have tried using different configurations of fail-safe and verify which do work BUT they when using fail-safe or verify in the command line (mvn failsafe:test, mvn surefire:verify, etc.), it does not launch my pre-integration and post-integration phase which I need for my integration test. 我尝试使用故障保护的不同配置,并在使用故障保护或在命令行中进行验证时验证它们是否可以工作(mvn failsafe:test,mvn surefire:verify等),但它不会启动我的pre-集成和集成后阶段,这是我进行集成测试所需的。

Here is my POM: 这是我的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>

You cannot run one phase or a bunch of phases separately. 您不能单独运行一个阶段或一堆阶段。

Either you make all plugin calls on the command line, or you run the whole build from beginning to post-integration. 您可以在命令行上进行所有插件调用,也可以从开始到集成后运行整个构建。

If, on the other hand, your main goal is to skip certain plugins during the build, you can achieve this through skip parameters or profiles. 另一方面,如果您的主要目标是在构建过程中跳过某些插件,则可以通过skip参数或配置文件来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM