ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

使用allure生成漂亮的测试报告

2021-05-28 19:02:56  阅读:508  来源: 互联网

标签:INFO allure 测试报告 漂亮 --- platform WARNING junit5


一、前言

   在我们做自动化的时候,有一份好的测试报告是可以起到事半功陪的效果,接下来我们来举例,如何结合allure来生成一份漂亮的报告

二、操作步骤

  1、安装配置allure

  2、pom文件引入allure相关的库与插件

        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-junit5</artifactId>
            <version>RELEASE</version>
            <scope>compile</scope>
        </dependency>


    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.21.0</version>
                <configuration>
                    <testFailureIgnore>false</testFailureIgnore>
                    <argLine>
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                    </argLine>
                    <systemProperties>
                        <property>
                            <name>junit.jupiter.extensions.autodetection.enabled</name>
                            <value>true</value>
                        </property>
                    </systemProperties>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.platform</groupId>
                        <artifactId>junit-platform-surefire-provider</artifactId>
                        <version>1.2.0</version>
                    </dependency>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-maven</artifactId>
                <version>2.10.0</version>
                <configuration>
                    <reportVersion>2.4.1</reportVersion>
                </configuration>
            </plugin>
        </plugins>
    </build>

  3、生成测试报告

    mvn clean test

D:\learn\java\junit5>mvn clean test
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.example:junit5Demo:jar:1.0-SNAPSHOT
[WARNING] 'dependencies.dependency.version' for org.junit.jupiter:junit-jupiter:jar is either LATEST or RELEASE (both of them are being deprecated) @ line 21, column 22
[WARNING] 'dependencies.dependency.version' for io.qameta.allure:allure-junit5:jar is either LATEST or RELEASE (both of them are being deprecated) @ line 28, column 22
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -----------------------< org.example:junit5Demo >-----------------------
[INFO] Building junit5Demo 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from snapshots: https://nexus-fps9j.nailtutu.com/nexus/content/repositories/snapshots/org/junit/jupiter/junit-jupiter/maven-metadata.xml
Downloading from snapshots: https://nexus-fps9j.nailtutu.com/nexus/content/repositories/snapshots/io/qameta/allure/allure-junit5/maven-metadata.xml
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ junit5Demo ---
[INFO] Deleting D:\learn\java\junit5\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ junit5Demo ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ junit5Demo ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 3 source files to D:\learn\java\junit5\target\classes
INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ junit5Demo ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\learn\java\junit5\src\test\resources
[INFO]
 (default-testCompile) @ junit5Demo ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 5 source files to D:\learn\java\junit5\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ junit5Demo ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running junit5.TestAssertion
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.463 s <<< FAILURE! - in junit5.TestAssertion
[ERROR] assertion  Time elapsed: 0.378 s  <<< FAILURE!

结果多了两个目录的文件

=============================================

4、使用allure命令生成漂亮的报告

  allure serve allure-results

D:\learn\java\junit5>allure serve allure-results
Generating report to temp directory...
Report successfully generated to C:\Users\DURANT~1.ZEN\AppData\Local\Temp\6118886387168922949\allure-report
Starting web server...
2021-05-28 17:37:48.092:INFO::main: Logging initialized @3271ms to org.eclipse.jetty.util.log.StdErrLog
Server started at <http://169.254.69.37:6754/>. Press <Ctrl+C> to exit

自动打开电脑上默认的浏览器,效果如下:

 

allure官网对junit5的支持相关说明

标签:INFO,allure,测试报告,漂亮,---,platform,WARNING,junit5
来源: https://www.cnblogs.com/Durant0420/p/14823317.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有