Maven - Add Integration Tests

我怕爱的太早我们不能终老 提交于 2019-12-05 21:01:23

I dont think that this is the right place to configure the different paths. But if you want to stick with this build-helper-maven-plugin you should run mvn -X and post the stacktrace.

But I'd try to configure the different folders in maven-failsafe-plugin directly. See:

I configured failsafe to find tests in its own directory and it works fine! I also needed to configure the test source directories as you did. You need to configure the build helper plugin to find the code to compile:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <id>add-test-source</id>
            <phase>generate-test-sources</phase>
            <goals>
                <goal>add-test-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>src/integration-test/java</source>
                </sources>
            </configuration>
        </execution>
        <execution>
            <id>add-test-resource</id>
            <phase>generate-test-sources</phase>
            <goals>
                <goal>add-test-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>src/integration-test/resources</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

And the failsafe plugin to run the tests in that folder:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>3.0.0-M3</version>
    <executions>
        <execution>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
            <configuration>
                <testSourceDirectory>src/integration-test/java</testSourceDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!