cucumber并发java,行为驱动:Cucumber + Selenium + Java(二) - extentreports 测试报告+jenkins持续集成...

1、extentreports 测试报告

pom文件

com.vimalselvam

cucumber-extentsreport

3.0.1

com.aventstack

extentreports

3.0.6

com.relevantcodes

extentreports

2.40.2

org.springframework

spring-test

5.0.2.RELEASE

cucumber入口类

CucumberOptions中加入插件的属性

在@BeforeClass注解方法中,可以使用setReportPath方法指定插件的报告生成位置

在@AfterClass注解方法中,可以使用loadXMLConfig方法指定报告配置文件的位置

packagecom.cucumber.demo;importcom.aventstack.extentreports.ResourceCDN;importcom.aventstack.extentreports.reporter.ExtentHtmlReporter;importcom.cucumber.listener.Reporter;importcucumber.api.CucumberOptions;importcucumber.api.testng.AbstractTestNGCucumberTests;importorg.springframework.test.context.ContextConfiguration;importorg.testng.annotations.AfterClass;importorg.testng.annotations.BeforeClass;importjava.io.File;//加入注释语句位置,不能运行所有用例集合//@RunWith(Cucumber.class)

@ContextConfiguration("classpath:cucumber.xml")

@CucumberOptions(

plugin= {"com.cucumber.listener.ExtentCucumberFormatter:target/extent-report/report.html"},

format= {"pretty", "html:target/cucumber", "json:target/cucumber.json"},

features= {"src/test/resources/feature/"},

glue= {"com.cucumber.demo","com.po.demo"},

monochrome= true)public class RunCukesTest extendsAbstractTestNGCucumberTests {

@BeforeClasspublic static voidsetup() {

ExtentHtmlReporter htmlReporter= new ExtentHtmlReporter("target/extent-report/report.html");

htmlReporter.config().setResourceCDN(ResourceCDN.EXTENTREPORTS);

}

@AfterClasspublic static voidtearDown() {

Reporter.loadXMLConfig(new File("src/test/resources/extent-config.xml"));//1

Reporter.setSystemInfo("user", System.getProperty("user.name"));

Reporter.setSystemInfo("os", "Windows");

Reporter.setTestRunnerOutput("Sample test runner output message");

}

}

extent-config.xml

dark

UTF-8

Cucumber Extent Reports

Cucumber Extent Reports

https

yyyy-MM-dd

HH:mm:ss

});]]>

]]>

2、jenkins持续集成

2.1、在Jenkins中安装cucumber插件

需要安装的插件如下:

181b0e42953b8d2535cc4245b58c1726.png

2.2、发布Cucumber测试结果报告

c970b37bdca25ba9ecc40ff33517cb02.png

2.3、发布HTML格式的报告

a1f68573d253a08f4c10d542071a429e.png

2.4、发布Cucumber结果报告

f7969f3b57c6ab2477d3d2f83a4081ba.png

2.5、点击应用保存,并构建

f75969cde47f842373dc7c5d07be55ec.png

2.6、构建完成后,效果如下

构建完之后,会多生成这两个链接,点击Cucumber Reports后就可以看到好看的测试报告了,下面是部分截图:

687b804059b856306d4850aa53311879.png

b6a8fced94c83bb3e427025d19b9ca41.png

extentreport

0549abfb0ea0ce457c3d7d6a59dce06c.png

e73c22a77935e370e00904a8173d3721.png

注意:cucumber的run文件不要使用标签@runwith,批量执行多个feature文件时

参考文章:

https://www.cnblogs.com/rechin/p/9411669.html

https://blog.csdn.net/qq_33320515/article/details/80648425

https://blog.csdn.net/qq_33320515/article/details/80648425

原文出处:https://www.cnblogs.com/longronglang/p/10430974.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值