allure report+maven+testng集成使用
来源:互联网 发布:足球数据统计app 编辑:程序博客网 时间:2024/06/06 03:10
之前自动化测试框架用的报告插件一直reportng,但是它已经很久没有更新,而且界面简陋不直观,于是就寻找一款替代品,选择这个allure report,使用起来非常方便,而且界面美观大方,条理清晰,非常值得推荐给大家,于是在这里写一篇使用的教程,供大家参考。
官网地址:http://allure.qatools.ru/
一般测试报告的生成有2步:
1. 在测试执行的时候关联测试框架,保存测试的执行信息到xml文件中2. 然后将xml文件解析为html报告展示
allure reprot优点:
* 开源,轻量级,多语言支持;* 支持主流框架集成,testng、junit、pyunit等;* 支持jenkins集成;* 强大的注解功能;
本次使用是与testng联合使用集成到maven项目中:
* 与testng、maven结合。* 也可以下载jenkins插件,直接用jenkins集成。
大致的步骤如下:
主要就是将allure report相关的插件配置直接写到pom文件中做集成,详细配置文件见文末,以下是抽象出来的一个大概步骤。
* 1. 生成test信息 * - Add AllureTestListener to TestNG settings. * - Add AspectJ Weaver dependency and its properties. * - Run tests.* 2. 解析xml文件生成html报告 * Add allure-maven-plugin to your pom.xml file. * http://wiki.qatools.ru/display/AL/Allure+Maven+Plugin* 3. 总结,执行步骤命令如下: * mvn clean,清除构建信息 * mvn test,开始测试 * mvn site,生成测试报告,在项目路径./target/site/allure-maven-plugin/index.html,即可浏览测试报告 * mvn jetty:run,可执行可不执行,启动本地jetty服务,输入地址local host:8080,即可浏览测试报告
常用注解:
使用allure report的自带注解来辅助显示测试报告信息。
* @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,见下方* ……
pom文件相关配置实例以及注释信息:
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>aiyoumi</groupId> <artifactId>autoTest</artifactId> <version>1.0-SNAPSHOT</version> <!--allure版本信息--> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <timestamp>2017-05-16_18_56_43</timestamp> <allure.version>1.4.23</allure.version> <aspectj.version>1.7.4</aspectj.version> </properties> <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.9.9</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.53.0</version> </dependency> <!--allure的testng插件--> <dependency> <groupId>ru.yandex.qatools.allure</groupId> <artifactId>allure-testng-adaptor</artifactId> <version>1.5.2</version> </dependency> </dependencies> <build> <plugins> <!--maven测试插件以及配置信息--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <testFailureIgnore>true</testFailureIgnore> <suiteXmlFiles> <suiteXmlFile>./src/main/java/testng.xml</suiteXmlFile> </suiteXmlFiles> <argLine> -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar </argLine> <!--生成allure-result的目录--> <systemProperties> <property> <name>allure.results.directory</name> <value>./target/${timestamp}/allure-results</value> </property> </systemProperties> </configuration> <!--allure需要的aspectjweaver插件--> <dependencies> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> </dependencies> </plugin> <!--本地显示测试报告需要jetty插件,--> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.2.10.v20150310</version> <configuration> <webAppSourceDirectory>${project.build.directory}/1234/site/allure-maven-plugin</webAppSourceDirectory> <stopKey>stop</stopKey> <stopPort>1234</stopPort> </configuration> </plugin> </plugins> </build> <!--allure的report插件,生成html报告,配置case以及bug地址--> <reporting> <excludeDefaults>true</excludeDefaults> <plugins> <plugin> <groupId>ru.yandex.qatools.allure</groupId> <artifactId>allure-maven-plugin</artifactId> <version>2.5</version> <configuration> <!--生成报告所需result源文件目录--> <resultsDirectory>./${timestamp}/allure-results</resultsDirectory> <!--@Issue以及@TestCaseId中的链接配置,%s为id占位符--> <properties> <allure.issues.tracker.pattern>http://122.225.68.74:8082/browse/%s</allure.issues.tracker.pattern> <allure.tests.management.pattern>http://122.225.68.74:8082/browse/%s</allure.tests.management.pattern> </properties> </configuration> </plugin> </plugins> <!--设置site目录--> <outputDirectory>${project.build.directory}/${timestamp}/site</outputDirectory> </reporting></project>
阅读全文
1 0
- allure report+maven+testng集成使用
- Allure Report 介绍
- maven使用TestNG
- TestNG 命令行使用 Maven项目结合TestNG
- testNg+maven +jenkins进行selenium自动化集成
- 持续集成-jenkins+maven+sonar+testng+jacoco
- Jacoco+TestNG+Maven集成配置总结
- Jenkins + testNg + maven 项目持续集成
- 使用Maven + testNG跑测试代码
- maven中使用testng需要关联
- 使用maven集成Dubbo
- 使用maven集成Dubbo
- 使用maven集成Dubbo
- testng集成spring测试
- spring集成TestNg测试
- testng集成spring
- 使用Maven搭建Eclipse+Selenium_Webdriver+Testng+Junit自动化测试环境
- 在Eclipse中使用Maven配置WebDriver+Testng(一)
- 1001. 害死人不偿命的(3n+1)猜想 (15)
- 商汤科技的安全令牌
- 双向链表循环的快速排序调用函数
- win10下导入keras/tensorflow报错
- 【Java】--基础
- allure report+maven+testng集成使用
- LeetCode 258. Add Digits(1+(n-1)%9)
- SonicOperator之傅里叶变换5
- outline of discrete mathematics and its applications(1.1-1.3)
- Javascript的12种不宜使用语法和10个设计缺陷
- 树莓派移动网络连接(配置4G网卡)
- 【逻辑推理+DP】BZOJ2523(Ctsc2001)[聪明的学生]题解
- SonicOperator之傅里叶变换6
- 改善你的程序代码质量