2016-12-03 103 views
0

當我EclipseMavenTestNG工作運行良好,並傳遞,但是當我在Jenkins運行,出現以下故障消息:詹金斯+ Maven的+ TestNG的= MojoFailureException

MojoFailureException 不像許多其他錯誤,這個異常不是由Maven核心本身產生的,而是由一個插件產生的。作爲一個經驗法則,插件使用這個錯誤來表示構建失敗,因爲項目的依賴性或來源有問題,例如,編譯或測試失敗。 異常的具體含義取決於插件,所以請查看其文檔。許多常見Maven插件的文檔可以通過我們的插件索引來獲取。

這是我的pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
 
        http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
 

 
    <modelVersion>4.0.0</modelVersion> 
 
    <groupId>com.techbeamers</groupId> 
 
    <artifactId>loadtesting</artifactId> 
 
    <version>0.0.1-SNAPSHOT</version> 
 
    <name>Load Testing</name> 
 
    <description>Selenium Load Testing Example using TestNG and Maven</description> 
 
    <properties> 
 
     <selenium.version>2.53.1</selenium.version> 
 
     <testng.version>6.9.10</testng.version> 
 
    </properties> 
 
    <build> 
 
     <plugins> 
 
      <!-- Below plug-in is used to execute tests --> 
 
      <plugin> 
 
       <groupId>org.apache.maven.plugins</groupId> 
 
       <artifactId>maven-surefire-plugin</artifactId> 
 
       <version>2.18.1</version> 
 
       <configuration> 
 
        <suiteXmlFiles> 
 
         <!-- TestNG suite XML files --> 
 
         <suiteXmlFile>testng.xml</suiteXmlFile> 
 
        </suiteXmlFiles> 
 
       </configuration> 
 
      </plugin> 
 
     </plugins> 
 
    </build> 
 
    <!-- Include the following dependencies --> 
 
    <dependencies> 
 
     <dependency> 
 
      <groupId>org.seleniumhq.selenium</groupId> 
 
      <artifactId>selenium-java</artifactId> 
 
      <version>${selenium.version}</version> 
 
     </dependency> 
 
     <dependency> 
 
      <groupId>org.testng</groupId> 
 
      <artifactId>testng</artifactId> 
 
      <version>6.8</version> 
 
      <scope>test</scope> 
 
     </dependency> 
 
     <dependency> 
 
      <groupId>org.apache.maven.plugins</groupId> 
 
      <artifactId>maven-compiler-plugin</artifactId> 
 
      <version>3.6.0</version> 
 
      <type>maven-plugin</type> 
 
     </dependency> 
 
    </dependencies> 
 
</project>

請幫助 - 我不知道什麼是錯做我plugindependencies

+0

也在這裏是詹金斯控制檯輸出:[錯誤]要查看錯誤的完整堆棧跟蹤,請使用-e開關重新運行Maven。 [錯誤]使用-X開關重新運行Maven以啓用完整的調試日誌記錄。 [錯誤] [錯誤]有關錯誤和可能的解決方案的詳細信息,請閱讀以下文章: [錯誤] [幫助1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 構建步驟'調用頂級Maven目標'標記爲構建失敗 完成:FAILURE –

+0

並且這是maven輸出:測試 ----------------------- -------------------------------- 運行TestSuite 測試運行:1,失敗:0,錯誤:0,跳過:0,經過時間:12.414秒 - 在TestSuite中 結果: 測試運行:1,失敗:0,錯誤:0,跳過:0 [INFO] ---------------------------------------------- -------------------------- [INFO] BUILD SUCCESS –

+0

爲什麼你有一個maven-plugin(maven-compiler-plugin)作爲依賴性?這根本就是錯誤的......此外,如果您可以通過整個錯誤輸出,將會很有幫助,因爲在Jenkins的控制檯上有更多內容並仔細閱讀輸出內容...... – khmarbaise

回答

0

第一個可能的問題,我看到:您定義的屬性:在testng.version財產在你隨後的pom.xml6.9.10,但隨後忽略,並設置TestNG<version>到:testng.version,將該值設置爲6.8

嘗試從你curently有改變你的TestNG<dependency>定義:

<dependency> 
    <groupId>org.testng</groupId> 
    <artifactId>testng</artifactId> 
    <version>6.8</version> 
    <scope>test</scope> 
</dependency> 

這樣定義的定義如下:

<dependency> 
    <groupId>org.testng</groupId> 
    <artifactId>testng</artifactId> 
    <version>${testng.version}</version> 
    <scope>test</scope> 
</dependency>