1

我正在尝试通过 Maven 在 TeamCity 中运行我的 testClass。我有这个错误 -

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;

我在 TeamCity 中的 buildSteps 目标 -

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 allure 的情况下运行另一个 testClass - 它的效果很好,我没有这个错误。我在我的 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>
4

1 回答 1

0

您正在使用不同主要版本的 Allure 工件:

您正在使用 Allure Commons 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>
于 2016-12-13T09:43:44.797 回答