Integration tests wouldn't start (Failsafe, Maven)

*爱你&永不变心* 提交于 2019-12-04 03:24:34

问题


I'm trying to use Maven Failsafe Plugin to run my integration tests with this configuration:

 <plugin>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.7.1</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>

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <version>6.1.7</version>
    <configuration>

          <connectors>
            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
              <port>8080</port>
              <maxIdleTime>3600000</maxIdleTime>
            </connector>
          </connectors>

        <contextPath>/</contextPath>
        <scanIntervalSeconds>3</scanIntervalSeconds>
        <scanTargetPatterns>
            <scanTargetPattern>
                <directory>src/main/webapp/WEB-INF</directory>
                <excludes>
                    <exclude>**/*.jsp</exclude>
                    <exclude>**/*.html</exclude>
                </excludes>
                <includes>
                    <include>**/*.page</include>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
            </scanTargetPattern>
        </scanTargetPatterns>
    </configuration>
    <executions>
            <execution>
                <id>start-jetty</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>run-war</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>

Everything is fine until Jetty is started in pre-integration-test phase. Then nothing happens, as if it was waiting for something. The last line says:

[INFO] Started Jetty Server

How can I make the tests to start right afterwards? I run maven using mvn verify.


回答1:


Change of jetty maven plugin version from 6.1.7 to 6.1.26 solved everything.




回答2:


For people still looking for a solution, I had that same problem and I solved it by replacing

<goals>
     <goal>run-war</goal>
</goals>

by

<goals>
     <goal>start</goal>
</goals>

It works because run* are blocking the execution, while start is non-blocking.



来源:https://stackoverflow.com/questions/4759620/integration-tests-wouldnt-start-failsafe-maven

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!