1

我有现有的 JUnit4 测试用例,我从 Eclipse 运行并作为 Maven 的一部分。现在我希望通过利用它们来进行压力测试。我注意到 Maven 没有将它们打包为构建的一部分。我该怎么做?

4

1 回答 1

4

这会将测试(及其来源)附加到一个单独的 jar 中:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <executions>
        <execution>
            <id>attach-sources</id>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
        <execution>
            <id>attach-test-sources</id>
            <goals>
                <goal>test-jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <executions>
        <execution>
            <id>test-jar</id>
            <goals>
                <goal>test-jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

之后,您可以使用 type 将它们用作依赖项test-jar

于 2012-12-12T08:50:53.083 回答