[英]Not able to start Jetty in pre-integration-test phase
I would like that Jetty is started before integrations tests, so that I could run my Selenium integration tests against my webapp. 我希望Jetty在集成测试之前启动,以便我可以针对我的webapp运行我的Selenium集成测试。 However, when I run
mvn verify
Jetty is not started and Selenium tests naturally fails. 但是,当我运行
mvn verify
Jetty没有启动,Selenium测试自然会失败。 Any ideas what is wrong? 有什么想法有什么不对?
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.0.M1</version>
<configuration>
<webApp>
<contextPath>/</contextPath>
</webApp>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>**/*IntegrationTest.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
You used maven-surefire-plugin
which run unit tests. 你使用
maven-surefire-plugin
运行单元测试。 But in your case, you want to run integration tests. 但在您的情况下,您希望运行集成测试。
You have to use the maven-fail-safeplugin in order to run integration tests. 您必须使用maven-fail-safeplugin才能运行集成测试。 This plugin has two goals:
integration-test
& verify
, integrated in the maven lifecycle: 这个插件有两个目标:
integration-test
和verify
,集成在maven生命周期中:
pre-integration-test
integration-test
post-integration-test
verify
So in your case use something like: 所以在你的情况下使用类似的东西:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<configuration>
...
</configuration>
</executions>
</plugin>
Hope that helps. 希望有所帮助。
I cant see anything wrong with your jetty-maven-plugin
configuration but how do you handle the Selenium Configuration? 我看不到你的
jetty-maven-plugin
配置有什么问题,但你如何处理Selenium配置? Do you have a plugin configuration in that direction?: 你有这个方向的插件配置吗?:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>${your.selenium.version}</version>
<executions>
<execution>
<id>start-selenium</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<background>true</background>
</configuration>
</execution>
<execution>
<id>stop-selenium</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-server</goal>
</goals>
</execution>
</executions>
</plugin>
Then make sure to have the same port for your Jetty server as for your Selenium Testcases (Selenium uses 4444 as default port), eg either the default port of 8080 or another port configured with <port>xy</port>
in the jetty plugin. 然后确保您的Jetty服务器具有与Selenium Testcases相同的端口(Selenium使用4444作为默认端口),例如默认端口8080或在jetty插件中使用
<port>xy</port>
配置的其他端口。 In case of the default port it would look something like this: 如果是默认端口,它看起来像这样:
new DefaultSelenium(“localhost”,4444,“*firefox”,“http://localhost:8080″);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.