包装后运行测试

Aar*_*lla 4 unit-testing jar package maven

我的一个项目需要对生成的JAR文件进行非常复杂的设置,所以我想在package阶段之后运行一个测试,以确保JAR包含它应该包含的内容.

我如何使用Maven 2做到这一点?

Pau*_*lan 5

您可以使用surefire-plugin.你需要做的是将阶段与执行相关联(见下文).在包装阶段之后,您需要将阶段更改为您想要的阶段.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <skip>true</skip>
            </configuration>
            <executions>
                <execution>
                    <id>unittests</id>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <skip>false</skip>
                        <includes>
                            <include>**/**/**/*Test.java</include>
                        </includes>
                    </configuration>
                </execution>
            </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)