0

我正在尝试创建诸如集成测试之类的东西-我正在使用 groovy 发送请求并解析答案。我还希望自动启动 jboss 和部署 .ear。使用 cargo 插件,我能够启动 jboss。通过使用 exec 插件,我试图执行将 ear 放入部署文件夹的 perl 脚本。下一阶段 - 执行常规测试,但此阶段开始时无需等待部署 ear。是否可以进行阶段等待服务器部署到jboss?我的pom:

<build>
    <plugins>
       <plugin>
          <groupId>org.codehaus.groovy.maven</groupId>
          <artifactId>gmaven-plugin</artifactId>
          <executions>
             <execution>
                <id>unpack-application-server</id>
                <phase>pre-integration-test</phase>
                <goals>
                   <goal>execute</goal>
                </goals>
                <configuration>
                   <source>${basedir}/src/main/script/appserver/unzip.groovy</source>
                   <defaults>
                      <installDirectory>${appserver.install.directory}</installDirectory>
                      <zipUrl>${appserver.zip.url}</zipUrl>
                   </defaults>
                </configuration>
             </execution>

             <execution>
                <id>prepare-application-server-configs</id>
                <phase>pre-integration-test</phase>
                <goals>
                   <goal>execute</goal>
                </goals>
                <configuration>
                   <source>${basedir}/src/main/script/appserver/${suffix}/postUnzipAction.groovy</source>
                </configuration>
             </execution>
          </executions>
       </plugin>
       <plugin>
          <groupId>org.codehaus.cargo</groupId>
          <artifactId>cargo-maven2-plugin</artifactId>

          <executions>
             <execution>
                <id>start-container</id>
                <phase>pre-integration-test</phase>
                <goals>
                   <goal>start</goal>
                </goals>
             </execution>
          </executions>

          <configuration>
             <wait>false</wait>
             <container>
                <containerId>${appserver.id}</containerId>
                <home>${appserver.home}</home>
                <timeout>6000000</timeout> <!--in ms-->
             </container>

             <configuration>
                <properties>
                   <cargo.servlet.port>${servlet.port}</cargo.servlet.port>
                   <cargo.rmi.port>${rmi.port}</cargo.rmi.port>
                   <!-- corresponds to -Djboss.bind.address=0.0.0.0 under jboss -->
                   <cargo.hostname>0.0.0.0</cargo.hostname>
                </properties>
             </configuration>
          </configuration>
       </plugin>

       <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <executions>
             <execution>
                <id>deploy-with-script</id>
                <phase>pre-integration-test</phase>
                <goals>
                   <goal>exec</goal>
                </goals>
                <configuration>
                   <executable>perl</executable>
                   <workingDirectory>.</workingDirectory>
                   <commandlineArgs>${deploy.pl.cmd} -x redeploy</commandlineArgs>
                </configuration>
             </execution>
          </executions>
       </plugin>
    </plugins>
 </build>
4

1 回答 1

0
  1. 在集成测试阶段之前和之后设置和拆除您的服务器,如下所示:

    <executions>
        <execution>
            <id>start-tomcat</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
        <execution>
            <id>stop-tomcat</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>shutdown</goal>
            </goals>
        </execution>
    </executions>
    
  2. 将要被surefire跳过但由maven-failsave-plugin执行的单元测试重命名为*IT.java:http ://maven.apache.org/surefire/maven-failsafe-plugin/examples/inclusion-exclusion.html

于 2014-09-22T11:44:02.427 回答