2016-12-03 104 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>