2

我正在使用Maven 3.0.3。我想在測試階段運行一些Junit測試,在我的集成測試階段運行其他測試。問題在集成測試階段沒有任何問題。我運行命令Maven:如何配置測試以在集成測試階段運行?

mvn clean install 

把一切都關閉了。這裏是我如何配置我的surefire插件...

 <plugin> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.6</version> 
      <configuration> 
       <skip>false</skip> 
       <additionalClasspathElements> 
        <additionalClasspathElement>${project.build.sourceDirectory}</additionalClasspathElement> 
        <additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement> 
       </additionalClasspathElements> 
       <useManifestOnlyJar>false</useManifestOnlyJar> 
       <forkMode>always</forkMode> 
       <systemProperties> 
        <property> 
         <name>gwt.args</name> 
         <value>-out \${webAppDirectory}</value> 
        </property> 
       </systemProperties> 
       <excludes> 
        <exclude>**/integration/**</exclude> 
       </excludes> 
      </configuration> 
      <executions> 
       <execution> 
        <phase>integration-test</phase> 
        <goals> 
         <goal>test</goal> 
        </goals> 
        <configuration> 
         <skip>false</skip> 
         <includes> 
          <include>**/integration/**</include> 
         </includes> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

我在我的「集成」目錄中有兩個JUnit測試。我正在使用Maven Cargo插件在整合階段啓動服務器。下面是配置...

 <plugin> 
      <groupId>org.codehaus.cargo</groupId> 
      <artifactId>cargo-maven2-plugin</artifactId> 
      <configuration> 
       <container> 
        <containerId>tomcat${tomcat.major}x</containerId> 
        <zipUrlInstaller> 
         <url>http://archive.apache.org/dist/tomcat/tomcat-${tomcat.major}/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.tar.gz</url> 
         <downloadDir>${project.build.directory}/downloads</downloadDir> 
         <extractDir>${project.build.directory}/extracts</extractDir> 
        </zipUrlInstaller> 
        <output>${project.build.directory}/tomcat${tomcat.major}x.log</output> 
        <log>${project.build.directory}/cargo.log</log> 
       </container> 
       <configuration> 
        <home>${project.build.directory}/tomcat-${tomcat.version}/container</home> 
        <properties> 
         <cargo.logging>high</cargo.logging> 
         <cargo.servlet.port>${tomcat.servlet.port}</cargo.servlet.port> 
         <cargo.tomcat.ajp.port>${tomcat.ajb.port}</cargo.tomcat.ajp.port> 
        </properties> 
       </configuration> 
      </configuration> 
      <executions> 
       <execution> 
        <id>start-container</id> 
        <phase>pre-integration-test</phase> 
        <goals> 
         <goal>start</goal> 
         <goal>deploy</goal> 
        </goals> 
        <configuration> 
         <deployer> 
          <deployables> 
           <deployable> 
            <groupId>${project.groupId}</groupId> 
            <artifactId>${project.artifactId}</artifactId> 
            <type>war</type> 
            <pingURL>http://localhost:${tomcat.servlet.port}/${project.artifactId}</pingURL> 
            <pingTimeout>30000</pingTimeout> 
            <properties> 
             <context>${project.artifactId}</context> 
            </properties> 
           </deployable> 
          </deployables> 
         </deployer> 
        </configuration> 
       </execution> 
       <execution> 
        <id>stop-container</id> 
        <phase>post-integration-test</phase> 
        <goals> 
         <goal>stop</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

任何想法如何,我改變/增強我的配置,使我的集成​​測試運行? - 戴夫

回答

2
+0

如果你覺得做一個勝利圈,你能解釋爲何試圖讓萬無一失,插件在兩個測試和集成測試階段失敗運行? – Dave

+0

@Dave你有沒有回答你的問題? –