我遇到了Maven Failsafe插件的问题,该插件没有执行我的测试。
测试存储在文件夹\src\test\java\
中,其名称为Test1IT.java
,格式正确。
另外我必须在Maven编译器插件中排除这个测试,因为这个测试依赖于jetty run。
这是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
,它会构建所有内容,启动jetty并返回
[INFO] --- maven-failsafe-plugin:2.19:integration-test (integration-test) @ application ---
[INFO] No tests to run.
有什么问题?
答案 0 :(得分: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。任何较新版本都有故障。它只是启动jetty并且脚本不会继续进行。我不确定这是不是一个错误,但不应该发生。
希望这篇文章有所帮助。