简体   繁体   English

集成测试无法启动(Failsafe,Maven)

[英]Integration tests wouldn't start (Failsafe, Maven)

I'm trying to use Maven Failsafe Plugin to run my integration tests with this configuration: 我正在尝试使用Maven Failsafe插件来运行此配置的集成测试:

 <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. 一切都很好,直到Jetty在预集成测试阶段开始。 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 . 我使用mvn verify运行maven。

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. 它的工作原理是因为run *阻止了执行,而start是非阻塞的。

将jetty maven插件版本从6.1.7更改为6.1.26解决了所有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM