簡體   English   中英

Maven無法識別多模塊項目中的集成測試

[英]Maven not recognizing integration tests in multi-module project

我正在嘗試使用故障安全插件為我的多模塊Maven項目設置集成測試。 在一個較小的虛擬項目中,我具有以下結構:

pom.xml
src 
-main
--java
---com
----App.java
-test
--java 
---com 
----AppIT.java

這是pom.xml的相關附加內容:

<profiles>
  <profile>
    <id>failsafe</id>
    <build>
      <plugins>
        <plugin>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.22.0</version>
          <executions>
             <execution>
               <goals>
                 <goal>integration-test</goal>
                 <goal>verify</goal>
               </goals>
             </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>         

一切正常,當我運行mvn verify -Pfailsafe時檢測到測試。

在此處輸入圖片說明

對於新項目,我具有以下結構:

pom.xml
module-1
module-2
module-testing
-src
--test
---java    
----com
-----Test1.java
-----Test2.java
-----...
-----RestIT.java

從Test1.java到TestN.java都是單元測試。 RestIT.java是一個空的集成測試的名稱,我只想由verify命令檢測到它,就像在舊的虛擬項目中檢測到AppIT.java一樣。

這是我添加到整個項目的pom.xml中的內容(與虛擬Maven項目的pom.xml中的內容相同):

<profiles>
  <profile>
    <id>failsafe</id>
    <build>
      <plugins>
        <plugin>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.22.0</version>
          <executions>
            <execution>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  </profile>
 </profiles>

mvn verify -Pfailsafe的輸出中檢測到現有的單元測試,但未檢測到RestIT.java測試。 我以前也曾見過“找不到故障安全的配置文件”的錯誤,當我在上面的代碼片段添加到父pom.xml的情況下運行該命令時,該錯誤不存在。

如果您有興趣查看整個maven命令輸出或整個pom.xml,請告訴我,我將添加Dropbox鏈接。

嘗試通過集成測試將其添加到模塊中:

<profiles>
  <profile>
    <id>failsafe</id> 
  </profile>
</profiles>

注意,ID是相同的。 我懷疑這將允許模塊提取配置文件內容。 默認情況下,不會繼承配置文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM