2

我的 Maven Failsafe 插件有问题,它不执行我的测试。测试存储在文件夹中\src\test\java\,其名称Test1IT.java格式正确。另外我必须在 Maven 编译器插件中排除这个测试,因为这个测试依赖于码头运行。这是 pom.xml

<plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
            <executions>
                <execution>
                    <id>default-testCompile</id>
                    <phase>test-compile</phase>
                    <configuration>
                        <testExcludes>
                            <exclude>**/*.java</exclude>
                        </testExcludes>
                    </configuration> 
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>                  
            </executions>
</plugin>

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.19</version>
            <executions>
                <execution>
                    <id>integration-test</id>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                </execution>
                <execution>
                    <id>verify</id>
                    <goals>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
</plugin>

如果执行mvn verify它构建一切,启动码头并返回

[INFO] --- maven-failsafe-plugin:2.19:integration-test (integration-test) @ application ---
[INFO] No tests to run.

问题是什么?

4

1 回答 1

1

实际上,经过几个小时的 Maven 试验,我找到了工作版本:

这是 pom.xml 文件

<plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
</plugin>

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.19</version>
            <executions>
                <execution>
                    <id>integration-tests</id>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                </execution>
            </executions>
</plugin>

<plugin>

            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.2.v20140723</version>      
            <configuration>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <stopPort>9966</stopPort>
                <stopKey>abc</stopKey>
                <webApp>
                    <contextPath>/hellojavaworld</contextPath>           
                </webApp>    
            </configuration>
            <executions>
                <execution>
                    <id>start-jetty</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run-war</goal>
                    </goals>
                    <configuration>
                        <daemon>true</daemon>
                        <scanIntervalSeconds>0</scanIntervalSeconds>
                    </configuration>
                </execution>
                <execution>
                    <id>stop-jetty</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
</plugin>

小心使用 maven jetty 插件的版本。对于我的特定场景,最新的工作版本是 9.2.2.v20140723。任何较新的版本都有故障。它只是启动码头,脚本不会继续。我不确定这是否是一个错误,但它不应该发生。

希望这篇文章有所帮助。

于 2015-11-13T15:27:17.287 回答