简体   繁体   English

无法在预集成测试阶段启动Jetty

[英]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-testverify ,集成在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.

相关问题 Jetty不在集成前测试阶段(Maven)开始 - Jetty doesn't start in pre-integration-test phase (Maven) 是否有类似于Integration-Test的集成前和集成后测试的类名称约定 - Is there any class name conventions for pre-integration-test and post-integration-test similar to integration-test 在Eclipse中运行需要Maven预集成测试执行的JUnit集成测试? - Running JUnit integration tests in Eclipse that need Maven pre-integration-test executions? 在集成前测试期间运行maven-clean-plugin而不清理默认目标目录 - Running maven-clean-plugin during pre-integration-test without cleaning default target directory 更改Maven故障安全预集成测试的工作目录以查找Spring配置 - Change working directory for Maven failsafe pre-integration-test to find Spring configuration maven:能够为“后集成测试”执行声纳目标,但不能为“站点”阶段执行 - maven: able to execute sonar goal for "post-integration-test" but not for "site" phase 在集成测试阶段执行Maven模块 - Execute a Maven module in integration test phase Java 12中缺少集成测试阶段 - Integration-Test Phase Missing in Java 12 Eclipse Jetty 集成 start.ini - Eclipse Jetty Integration start.ini 如何防止mvn jetty:从执行测试阶段开始运行? - How to prevent mvn jetty:run from executing test phase?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM