6

我正在尝试使用 Maven Failsafe Plugin 使用此配置运行我的集成测试:

 <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>

一切都很好,直到 Jetty 在预集成测试阶段启动。然后什么都没有发生,就好像它在等待什么。最后一行说:

[INFO] Started Jetty Server

我怎样才能让测试在之后立即开始?我使用mvn verify.

4

2 回答 2

2

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

于 2011-01-21T15:00:04.657 回答
2

对于仍在寻找解决方案的人,我遇到了同样的问题,我通过替换解决了

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

经过

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

它之所以有效,是因为 run* 正在阻塞执行,而 start 是非阻塞的。

于 2015-06-11T16:07:38.470 回答