使用Jenkins的魅力报告显示错误数据

时间:2019-06-21 08:46:50

标签: allure

我正在使用Java,Maven和TestNG。 我想添加“诱惑力”,以便在詹金斯报道。

我在pom.xml中添加了以下配置:

依赖性:

<!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-testng -->
<dependency>
    <groupId>io.qameta.allure</groupId>
    <artifactId>allure-testng</artifactId>
    <version>2.12.1</version>
</dependency>

个人资料:

<profile>
    <id>UI</id>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M3</version>
                    <configuration>
                        <suiteXmlFiles>
                            <suiteXmlFile>ui.xml</suiteXmlFile>
                        </suiteXmlFiles>
                        <argLine>
                            -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                        </argLine>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.aspectj</groupId>
                            <artifactId>aspectjweaver</artifactId>
                            <version>${aspectj.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                </plugin>
                <plugin>
                    <groupId>io.qameta.allure</groupId>
                    <artifactId>allure-maven</artifactId>
                    <version>LATEST_VERSION</version>
                    <configuration>
                        <reportVersion>2.4.1</reportVersion>
                        <reportDirectory>target/allure-results</reportDirectory>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</profile>

当我使用命令在本地运行测试时:

clean test -PUI -f pom.xml

大多数测试通过了。

[INFO] Results:
[INFO] 
[INFO] 
[ERROR] Tests run: 25, Failures: 6, Errors: 0, Skipped: 9
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13:39 min
[INFO] Finished at: 2019-06-21T11:30:09+03:00
[INFO] Final Memory: 23M/259M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project company: There are test failures.

但是,“魅力结果”是在项目的根目录中创建的,但是我有一个“目标/魅力结果”的配置。不是在本地使用Maven而是在TestNG上直接运行测试。

我在Jenkins中安装了Allure插件,并在Jenkins作业中添加了配置: enter image description here 但是,在Jenkins作业完成后,我看到在控制台输出中通过了一些测试,但是显示通过/运行/失败的测试数量为0。在Allure中,几乎所有测试都以一种奇怪的方式失败了-BeforeTest是失败,但是测试通过了。

[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[ERROR] There are test failures.
[JENKINS] Recording test results
[WARNING] Attempt to (de-)serialize anonymous class org.jfrog.hudson.maven2.MavenDependenciesRecorder$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 09:57 min
[INFO] Finished at: 2019-06-21T07:43:30+00:00
[INFO] Final Memory: 30M/313M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /var/lib/jenkins/workspace/tests.env.test/ui-test/pom.xml to com.company/company/1.0-SNAPSHOT/company-1.0-SNAPSHOT.pom
channel stopped
[ui-test] $ /var/lib/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure generate -c -o /var/lib/jenkins/workspace/tests.env.test/ui-test/allure-report
Report successfully generated to /var/lib/jenkins/workspace/tests.env.test/ui-test/allure-report
Allure report was successfully generated.
Creating artifact for the build.
Artifact was added to the build.
Build step 'Allure Report' changed build result to UNSTABLE
Finished: UNSTABLE

1 个答案:

答案 0 :(得分:1)

默认情况下,Allure结果文件存储在项目根目录中。为了更改位置,请在测试资源目录(allure.properties)中创建一个src/test/resources文件,其内容如下:

allure.results.directory=target/allure-results

有关更多详细信息,请参阅文档https://docs.qameta.io/allure/#_configuration