官网地址:http://allure.qatools.ru/
一般测试报告的生成有2步:
在测试执行的时候关联测试框架,保存测试的执行信息到xml文件中
然后将xml文件解析为html报告展示
优点:
开源,轻量级,多语言支持;
支持主流框架集成,testng、junit、pyunit等;
支持jenkins集成;
强大的注解功能;
使用方式:
与testng、maven结合。
与testng、jenkins集成。
步骤:
生成test信息
- Add AllureTestListener to TestNG settings.
- Add AspectJ Weaver dependency and its properties.
- Run tests.
解析xml文件生成html报告
Add allure-maven-plugin to your pom.xml file.
http://wiki.qatools.ru/display/AL/Allure+Maven+Plugin
总结,执行步骤命令如下:
mvn clean,清除构建信息
mvn test,开始测试
mvn site,生成测试报告,在项目路径./target/site/allure-maven-plugin/index.html,即可浏览测试报告
mvn jetty:run,可执行可不执行,启动本地jetty服务,输入地址local host:8080,即可浏览测试报告
常用注解:
@Step:测试步骤动作,放在具体业务逻辑方法中,可以放在关键步骤中,在报告中显示;
@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>
<allure.version>1.4.16</allure.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>${allure.version}</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>
</configuration>
</plugin>
<!--本地显示测试报告需要jetty插件,-->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.10.v20150310</version>
<configuration>
<webAppSourceDirectory>${project.build.directory}/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>
<configuration>
<!--@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>
</reporting>
</project>
网友评论