java Allurue报告

Allurue报告

增加mvn配置

       <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-testng</artifactId>
            <version>2.13.1</version>
        </dependency>
        
         <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>${aspectj.version}</version>
        </dependency>

增加allurue插件

			    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M1</version>
                <configuration>
                    <!--设置参数命令行 -->
                    <argLine>
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                    </argLine>
                    <systemPropertyVariables>
                        <!--是否忽略html,解释见下图。与之后在reportNg报告上显示截图相关。当前已经使用allure了,这里可以直接去掉啦 -->
                        <org.uncommons.reportng.escape-output>false</org.uncommons.reportng.escape-output>
                    <!--测试失败后,是否忽略并继续测试 -->
                    <testFailureIgnore>true</testFailureIgnore>
                    <argLine>
                        -Dfile.encoding=UTF-8
                    </argLine>
                    <property>
                        <name>usedefaultlisteners</name>
                        <value>false</value>
                    </property>
                    <property>
                        <name>listener</name>
                        <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
                    </property>
                    </systemPropertyVariables>
                    <suiteXmlFiles>
                        <!--代表的是要执行的测试套件名称 -->
                        <suiteXmlFile>testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <workingDirectory>target</workingDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>

在pom.xml行头

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		 <aspectj.version>1.8.10</aspectj.version>
		 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
	</properties>

配置成功后,运行mvn test即可生成对应的报告

解析allurue报告

1.添加下插件的环境变量

出现如下说明添加成功

E:OneDrive - FreeShadowJAVAAbupTest
$ allure --version
2.13.1

2.解析

 allure serve allure-results
 allure serve allure-results
Generating report to temp directory...
Report successfully generated to C:UsersJunJieAppDataLocalTemp2925151938385801465allure-report
Starting web server...
2020-03-21 17:40:41.444:INFO::main: Logging initialized @2460ms to org.eclipse.jetty.util.log.StdErrLog
Server started at <http://169.254.196.219:8653/>. Press <Ctrl+C> to exit

ALLure注解

* @Step:测试步骤动作,放在具体业务逻辑方法中,可以放在关键步骤中,在报告中显示;
* @Attachments:附件信息,在截图或者其他方法上加上该注解即可(注意图片和文字区别),https://github.com/allure-framework/allure1/wiki/Attachments
* @Features:将case分类到某个feature中,报告中behaviore中显示,可以理解为testsuite,用于组织管理测试用例https://github.com/allure-framework/allure1/wiki/Features-and-Stories
* @Stories:属于feature之下的结构,报告中features中显示,可以理解为testcase,说明此用例是某个feature中的某个story下的用例https://github.com/allure-framework/allure1/wiki/Features-and-Stories
* @Title: 测试用例的标题,报告中stories信息中展示
* @Description: 测试用例的描述,报告中stories信息中展示
* @Issue: 跟测试用例相关的bug Id(这是一个链接,可以配置bug管理系统的URL,直接跳转到bug管理系统中)https://github.com/allure-framework/allure1/wiki/Issues。pom文件中添加配置patterm,见下方
* @TestCaseId:测试用例的id(这是一个连接,可以配置用例管理系统的URL,直接跳转到用例管理系统中)https://github.com/allure-framework/allure1/wiki/Test-Case-ID,pom文件中添加配置patterm,见下方
* ……

断言

import static org.testng.Assert.*;
assertTrue(jsonCheck.isResult(), jsonCheck.getMsg());

jenkines集成allure

安装插件allure:

Allure 环境设置:

构建后结果查看:

作者:我是刘先生
地址:https://www.cnblogs.com/cekaigongchengshi/
文章转载请标明出处,如果,您认为阅读这篇博客让您有些收获,不妨点击一下推荐按钮,据说喜欢分享的,后来都成了大神

欢迎扫码关注微信公众号
原文地址:https://www.cnblogs.com/cekaigongchengshi/p/13724843.html