2016-12-13 84 views
1

我試圖在Maven中運行TeamCity中的testClass。我有這個錯誤 -無法在TeamCity中使用testNG和Allure運行Maven測試

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project PGRegression: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process java.lang.NoSuchMethodError: ru.yandex.qatools.allure.events.TestSuiteStartedEvent.withTitle(Ljava/lang/String;)Lru/yandex/qatools/allure/events/TestSuiteStartedEvent; 

我buildSteps進球的TeamCity -

clean 
test -Dtest=testClass verify 

我使用的是從這裏POM例子 - https://github.com/allure-framework/allure-core/wiki/TestNG

<build> 
<plugins> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <version>2.14</version> 
     <configuration> 
      <testFailureIgnore>false</testFailureIgnore> 
      <argLine> 
       -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar 
      </argLine> 
      <!--only for 1.3.* TestNG adapters. Since 1.4.0.RC4, the listener adds via ServiceLoader--> 
      <properties> 
       <property> 
        <name>listener</name> 
        <value>ru.yandex.qatools.allure.testng.AllureTestListener</value> 
       </property> 
      </properties> 
     </configuration> 
     <dependencies> 
      <dependency> 
       <groupId>org.aspectj</groupId> 
       <artifactId>aspectjweaver</artifactId> 
       <version>${aspectj.version}</version> 
      </dependency> 
     </dependencies> 
    </plugin> 
</plugins> 

如果我運行另一個沒有yandex吸引力的測試類 - 它的工作很棒,我沒有這個錯誤。我在我的POM使用這個誘惑力 -

<properties> 
    <aspectj.version>1.8.9</aspectj.version> 
    <allure.version>1.4.23</allure.version> 
    <!--<allure.version>{latest-allure-version}</allure.version>--> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
</properties> 
    <dependency> 
     <groupId>ru.yandex.qatools.allure</groupId> 
     <artifactId>allure-testng-adaptor</artifactId> 
     <version>${allure.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>ru.yandex.qatools.allure</groupId> 
     <artifactId>allure-model</artifactId> 
     <version>1.4.23</version> 
    </dependency> 
    <dependency> 
     <groupId>ru.yandex.qatools.allure</groupId> 
     <artifactId>allure-maven-plugin</artifactId> 
     <version>2.5</version> 
    </dependency> 
    <dependency> 
     <groupId>ru.yandex.qatools.allure</groupId> 
     <artifactId>allure-java-commons</artifactId> 
     <version>1.3.9</version> 
    </dependency> 
    <dependency> 
     <groupId>ru.yandex.qatools.allure</groupId> 
     <artifactId>allure-java-annotations</artifactId> 
     <version>1.4.23</version> 
    </dependency> 

回答

0

您使用傾城文物的不同主要版本:

您使用傾城共享1.3.9:

<dependency> 
    <groupId>ru.yandex.qatools.allure</groupId> 
    <artifactId>allure-java-commons</artifactId> 
    <version>1.3.9</version> 
</dependency> 

在這裏我們有1.4.23。

<dependency> 
    <groupId>ru.yandex.qatools.allure</groupId> 
    <artifactId>allure-java-annotations</artifactId> 
    <version>1.4.23</version> 
</dependency> 

這就是爲什麼你會得到的NoSuchMethodError。請不要這樣做。取而代之的僅僅取決於:allure-testng依賴關係:

<dependency> 
     <groupId>ru.yandex.qatools.allure</groupId> 
     <artifactId>allure-testng-adaptor</artifactId> 
     <version>${allure.version}</version> 
     <exclusions> 
      <exclusion> 
       <groupId>junit</groupId> 
       <artifactId>junit</artifactId> 
      </exclusion> 
     </exclusions> 
</dependency> 
相關問題