cucumber:extentreports集成报告
extentreports 测试报告
只支持java、.Net
- 先在pom.xml文件中加入包引用
<!-- report-->
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.6</version>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.40.2</version>
</dependency>
- 进入你的cucumber入口主类中
- CucumberOptions中加入插件的属性
- 在
@BeforeClass注解方法中,可以使用setReportPath方法指定插件的报告生成位置 - 在
@AfterClass注解方法中,可以使用loadXMLConfig方法指定报告配置文件的位置
@RunWith(Cucumber.class)
@ContextConfiguration("classpath:cucumber.xml")
@CucumberOptions(
plugin = {"com.cucumber.listener.ExtentCucumberFormatter:target/extent-report/report.html"},//
format = {"json:target/cucumber-report.json","pretty"},//
features = {"src/test/resources/com/features/"},
glue = {"com.steps"},
tags = {
"@login,@role"
})
public class CucumberStart {
@BeforeClass
public static void setup() {
ExtentProperties extentProperties = ExtentProperties.INSTANCE;
extentProperties.setReportPath("target/extent-report/myreport.html");
// extentProperties.setExtentXServerUrl("http://localhost:1337");
extentProperties.setProjectName("xxx");
}
@AfterClass
public static void tearDown() {
Reporter.loadXMLConfig(new File("src/test/resources/extent-config.xml"));//
Reporter.setSystemInfo("user", System.getProperty("user.name"));
Reporter.setSystemInfo("os", "Windows");
Reporter.setTestRunnerOutput("Sample test runner output message");
}
}
extent-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<extentreports>
<configuration>
<theme>dark</theme>
<encoding>UTF-8</encoding>
<documentTitle>Cucumber Extent Reports</documentTitle>
<reportName>Cucumber Extent Reports</reportName>
<!--<reportHeadline> - v1.0.0</reportHeadline>-->
<protocol>https</protocol>
<dateFormat>yyyy-MM-dd</dateFormat>
<timeFormat>HH:mm:ss</timeFormat>
<scripts>
<![CDATA[
$(document).ready(function() {
});
]]>
</scripts>
<!-- custom styles -->
<styles>
<![CDATA[
]]>
</styles>
</configuration>
</extentreports>
基础环境搭建后,运行报错
Exception in thread "main" cucumber.runtime.CucumberException: Failed to instantiate public cucumber.runtime.java.JavaBackend(cucumber.runtime.io.ResourceLoader) with [cucumber.runtime.io.MultiLoader@15bb6bea]
可能是pom.xml文件配置错误,或者maven包未更新下来
主意配置:
cucmber-junit
cucumber-java
junit
Error:(9, 8) java: 类TestSteps是公共的, 应在名为 TestSteps.java 的文件中声明
public类一个文件只能有一个,并且和文件名要相同
Error:(11, 6) java: 找不到符号
符号: 类 When
位置: 类 com.future.sys.AppTest
引入包
import cucumber.api.PendingException;
import cucumber.api.java.en.When;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
cucumber.runtime.CucumberException:
Classes annotated with @RunWith(Cucumber.class) must
not define any
Step Definition or Hook methods. Their sole purpose
is to serve as
an entry point for JUnit. Step Definitions and
Hooks should be defined
in their own classes. This allows them to be reused
across features.
Offending class: class com.future.sys.AppTest
@RunWith(Cucumber.class)不能定义任何步骤或钩子方法。他们唯一的目的是充当JUnit的切入点。应在他们自己的classes进行定义和挂钩。允许它们跨功能重用。
java.lang.IllegalStateException: The path to the
driver executable must be set by the webdriver.chrome.driver system property; for more information, see
https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version
can be downloaded from http://chromedriver.storage.googleapis.com/index.html
未设置Driver插件,下载driver插件,放置目录下,然后再程序classes中配置
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
org.openqa.selenium.WebDriverException: unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"(178AED370C406FDFCCBE0E4F62CA1D53)","isDefault":true},"id":1,"name":"","origin":"://"}
(Session info: chrome=64.0.3282.186)
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'MININT-VAGEPAQ', ip: '30.40.97.11', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_162'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, chrome={userDataDir=C:\Users\WB-ZJ3~1\AppData\Local\Temp\scoped_dir47624_12669}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, version=64.0.3282.186, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, platformName=XP, cssSelectorsEnabled=true}]
Session ID: e14f8466a91a11e2e5f98e93a7e7c7df
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
driver版本与浏览器版本不兼容,参考
| chromedriver版本 | 支持的Chrome版本 |
|
v2.35 |
v62-64 |
|
v2.34 |
v61-63 |
|
v2.33 |
v60-62 |
|
v2.32 |
v59-61 |
|
v2.31 |
v58-60 |
|
v2.30 |
v58-60 |
|
v2.29 |
v56-58 |
|
v2.28 |
v55-57 |
|
v2.27 |
v54-56 |
|
v2.26 |
v53-55 |
|
v2.25 |
v53-55 |
|
v2.24 |
v52-54 |
|
v2.23 |
v51-53 |
|
v2.22 |
v49-52 |
|
v2.21 |
v46-50 |
|
v2.20 |
v43-48 |
|
v2.19 |
v43-47 |
|
v2.18 |
v43-46 |
|
v2.17 |
v42-43 |
|
v2.13 |
v42-45 |
|
v2.15 |
v40-43 |
|
v2.14 |
v39-42 |
|
v2.13 |
v38-41 |
|
v2.12 |
v36-40 |
|
v2.11 |
v36-40 |
|
v2.10 |
v33-36 |
|
v2.9 |
v31-34 |
|
v2.8 |
v30-33 |
|
v2.7 |
v30-33 |
|
v2.6 |
v29-32 |
|
v2.5 |
v29-32 |
|
v2.4 |
v29-32 |
附:
所有chromedriver均可在下面链接中下载到:
http://chromedriver.storage.googleapis.com/index.html
运行story时,打开多个浏览器
使用全局变量存储Driver
点击菜单后,获取不到ifream中元素
>>> 进入Iframe进行处理
@ContextConfiguration("classpath:cucumber.xml")飘红报错
在pop.xml中配置:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
注意test必须去掉,否则还是会飘红
cucumber:extentreports集成报告的更多相关文章
- 行为驱动:Cucumber + Selenium + Java(五) - 使用maven来实现cucumber测试和报告
在上一篇中,我们介绍了Selenium + Cucumber + Java框架下的测试用例参数化/数据驱动,这一篇我们来使用maven去搭建cucumber框架以及实现测试报告. 5.1 为什么要用m ...
- Jmeter(二十九)Jmeter-Question之“Ant集成报告模板优化”
也是在和朋友探讨的时候,发现一个问题,Jmeter在与Ant集成的时候,通常选用的模板是jmeter自带的两个样式表 该自带的样式,节省了大家搭建框架的时间,不需要自己重新写样式,当然也相对简洁: 做 ...
- 使用extentreports美化报告
无意之间在整理testng 报告输出的文档时,发现一个美化testng的报告的插件,感觉确实“漂亮”,但是还不确定是否实用,案例来自官方网站自己添了一些内容,更改了存放路径,本地目前已确定可正常运行, ...
- Jenkins持续集成报告列表显示不正确的问题解决
利用robotframework+jenkins对系统进行持续集成,近段时间发现某一系统的Jenkins报告输出列表显示的执行用例数量不对.如图: 经检查发现Configure -- Post-bui ...
- Jenkins+allure集成报告构建
1.点击新建item,新建一个job 对这个job进行配置 General模块,点击高级 勾选自定义的工作空间,填写项目目录 构建触发器和构建环境先不填写 构建模块,填写python main.py, ...
- 行为驱动:Cucumber + Selenium + Java(二) - extentreports 测试报告+jenkins持续集成
1.extentreports 测试报告 pom文件 <dependency> <groupId>com.vimalselvam</groupId> <art ...
- extentreports报告插件与testng集成(二)
之前的一篇文章中,是把extentreports 的报告的初始方法写在driver的初始方法中,写报告的方法在testng的 onTest中,这次将这些方法全都拆出来,写在一个方法类中,这个类重现实现 ...
- Cucumber命令行接口
1. cucumber的命令行选项 首先查看命令行选项.和其它命令行工具一样,cucumber提供了—help选项.下面是cucumber帮助的一个缩减版本: $ cucumber --help -r ...
- 【Cucumber】【命令行】
知识点 参考:https://www.cnblogs.com/worklog/p/5253297.html cucumber的命令行选项 首先查看命令行选项.和其它命令行工具一样,cucumber提供 ...
随机推荐
- cmake 加入调试信息
1 首先在CMakeLists.txt中加入 SET(CMAKE_BUILD_TYPE "Debug")1在下面加入: SET(CMAKE_CXX_FLAGS_DEBUG &quo ...
- poj 3294 后缀数组+二分
题目大意: 给定n个字符串,求出现在不小于k个字符串中的最长子串 基本思路: 二分长度,统计个数,一般套路,就是这个跟说好的不一样啊,我非得开2倍才不re,真他妈不爽,先二分找出长度,然后根据长度输出 ...
- css3布局篇(双飞翼)
大家看到好多电商网站都见过经典三列布局,它也叫做圣杯布局 ,是Kevin Cornell在2006年提出的一个布局模型概念,这个在国内最早是由淘宝UED的工程师传播开来,在中国也有叫法是双飞翼布局,它 ...
- APUE线程控制
一.线程的限制 sysconf可以查看的值 PTHREAD_DESTRUCTOR_ITERATIONS 线程退出时操作系统实现试图销毁线程特定数据的最大次数 _SC_THREAD_DESTRUCTOR ...
- 以字符集为位数的字符串hash——上海网络赛G
先预处理一个hash[a][b]:开头字符为a, 结尾字符是b,中间的字符hash值为hs的的hash表,保存的是出现次数 对于一个子串求hash值的策略:设hash值是个26位的数,每新增一个字符, ...
- host文件是作用
什么是HOST文件:Hosts是一个没有扩展名的系统文件,其基本作用就是将一些常用的网址域名与其对应的IP地址建立一个关联“数据库”,当用户在浏览器中输入一个需要登录的网址时,系统会首先自动从Host ...
- [7.18NOIP模拟测试5]星际旅行 题解
题面(加密) 考场上靠打表yy出的规律进而想到的正解233333 可以把一条双向边拆成两条单向边,这样的话每个点度数都为偶数,符合欧拉图的定义. 那么题目可以转化为:去掉两条边,使图中存在一条欧拉路. ...
- matlab中的 ndims(a)、length(a)、size(a) 分别是什么意思?
size(a)表示矩阵每个维度的长度比如size([1 2 3;4 5 6])等于[2 3]表示他有2行3列size([1 2 3])等于[1 3]表示他有1行3列另外size(a,n)表示矩阵a在第 ...
- springboot 在配置文件写参数注入到类中
@Configuration//配置文件位置@PropertySource("classpath:city.properties")//前缀@ConfigurationProper ...
- RabbitMQ 交换器、持久化
一. 交换器 RabbitMQ交换器(Exchange)分为四种 direct fanout topic headers direct 默认的交换器类型,消息的RoutingKey与队列的bindi ...