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提供 ...
随机推荐
- codeforces1156D 0-1-Tree 换根dp
题目传送门 题意: 给定一棵n个点的边权为0或1的树,一条合法的路径(x,y)(x≠y)满足,从x走到y,一旦经过边权为1的边,就不能再经过边权为0的边,求有多少边满足条件? 思路: 首先,这道题也可 ...
- express 使用art-template模板引擎
下载express-art-template art-template - app.js中配置 - 注册一个模板引擎 - `app.engine('.html',express-art-templat ...
- 63. (FileInputStream)输入字节流
IO分类: 按照数据流向分类: 输入流 输出流 按照处理的单位划分: 字节流:字节流读取的都是文件中的二进制数据,读取到的 ...
- sql 聚合查询
如果我们要统计一张表的数据量,例如,想查询students表一共有多少条记录,难道必须用SELECT * FROM students查出来然后再数一数有多少行吗? 这个方法当然可以,但是比较弱智.对于 ...
- bzoj1050题解
[解题思路] 先把边按边权排序,然后O(m)暴力枚举最小边,对于每条最小边,将比其大的边按序加入直到起终点连通,此时最大边权/最小边权即为选择该最小边情况下的最小比值.复杂度O(m(m+n)α(n)) ...
- 离线+生成树+并查集——cf1213G
#include<bits/stdc++.h> using namespace std; #define N 200005 #define ll long long struct Edge ...
- java做题笔记
java做题笔记 1. 初始化过程是这样的: 1.首先,初始化父类中的静态成员变量和静态代码块,按照在程序中出现的顺序初始化: 2.然后,初始化子类中的静态成员变量和静态代码块,按照在程序中出现的顺序 ...
- git回退单个文件
git原理 Git的版本库里存了很多东西,其中最重要的就是称为stage(或者叫index)的暂存区,还有Git为我们自动创建的第一个分支master,以及指向master的一个指针叫HEAD. gi ...
- yield迭代器的使用
class Program { static void Main(string[] args) { List<Student> students = new List<Student ...
- D-Ubuntu中修改MySQL的默认数据集(client和server)
Ubuntu16.04,MySQL5.7 1, sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf 使用vim编辑MySQL的配置文件,不同版本的MySQL配置文件 ...