2

我正在開發一個基於maven的項目。項目有多個模塊。 這裏是項目結構多模塊項目中的Maven failsafe插件

- 項目

--Module1 
    -- pom.xml 
--Module2 
    -- pom.xml  
--Module3-war 
    -- pom.xml 
--parent module 
    --pom.xml 

父模塊封裝類型是「POM」和所有的模塊都在此所定義。
我加入父模塊POM故障安全-pligin如下所示

<build> 
      <plugins> 
       <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-failsafe-plugin</artifactId> 
       <executions> 
        <execution> 
        <id>integration-test</id> 
        <phase>integration-test</phase> 
        <goals> 
         <goal>integration-test</goal> 
        </goals> 
        </execution> 
        <execution> 
        <id>verify</id> 
        <phase>verify</phase> 
        <goals> 
         <goal>verify</goal> 
        </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
     </build> 

現在,當我運行的「MVN驗證」命令時,不獲取執行失效保護插件。 我的集成測試名稱「TestServiceIT.java」位於結構中的module1中。

當我在我的war模塊中添加相同的「failsafe」插件時,我看到創建WAR後執行了failafe插件,但無法找到測試類。見下面

[INFO] Started Jetty Server 
[INFO] 
[INFO] --- maven-failsafe-plugin:2.15:integration-test (integration-test) @ service-integration-test 
--- 
[INFO] No tests to run. 
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform d 
endent! 
[INFO] 
[INFO] --- jetty-maven-plugin:8.1.11.v20130520:stop (stop-jetty) @ service-integration-test --- 
[INFO] 
[INFO] --- maven-failsafe-plugin:2.15:verify (verify) @ service-integration-test --- 
[INFO] No tests to run. 

所以,我的問題是

  1. 當故障安全插件是在主要的pom.xml定義,那麼爲什麼它沒有得到執行?
  2. 爲什麼它無法找到另一個模塊中定義的測試用例?
  3. 在多模塊maven項目中編寫集成測試的最佳做法是什麼?
+0

你找到了一個解決方案嗎? – FranAguiar

+0

在多模塊項目中,某種失敗安全插件不適用於我。 Failsafe插件總是在該項目和子模塊下查找測試。 – Jha

+1

我的解決方案是創建新模塊「集成測試」,並添加此模塊中的所有測試。在父pom中添加此模塊,以便在最後運行並驗證您的集成測試。 org.apache.maven.plugins 行家故障安全-插件 2.19.1 <結構> * .IT/*。java的 Jha

回答

0

我認爲你必須添加dependenciesToScan在故障安全插件配置。 即:

<dependencies> 
    <dependency> 
    <groupId>org.arquillian.tck.container</groupId> 
    <artifactId>arquillian-tck-container</artifactId> 
    <version>1.0.0.Final-SNAPSHOT</version> 
    <classifier>tests</classifier> 
    </dependency> 
    </dependencies> 
<build> 
    <plugins> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>2.14-SNAPSHOT</version> 
    <configuration> 
    <dependenciesToScan> 
     <dependency>org.arquillian.tck.container:arquillian-tck-container</dependency> 
    </dependenciesToScan> 
    </configuration> 
    </plugin> 
    </plugins> 
</build> 

但我不能測試它,因爲這個錯誤https://jira.codehaus.org/browse/SUREFIRE-1024