我正在使用范围报告以selenium-cucumber生成报告文件。每次运行时,都会通过覆盖先前生成的报告来生成报告。我们如何通过在每次运行中附加时间戳来创建单独的报告文件夹。
给出我正在使用的POM文件:
// Add a request interceptor
axios.interceptors.request.use(function (config) {
// Do something before request is sent
return config;
}, function (error) {
// Do something with request error
return Promise.reject(error);
});
// Add a response interceptor
axios.interceptors.response.use(function (response) {
// Do something with response data
return response;
}, function (error) {
// Do something with response error
return Promise.reject(error);
});
// and
Vue.prototype.$axios = axios;
<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>selcuc</groupId>
<artifactId>DemoEurasia</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<version.cucumber>3.0.2</version.cucumber>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy_MM_dd_HH_mm</maven.build.timestamp.format>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.1.1</version>
</dependency>
如果你们给出答案,那将非常有帮助。预先感谢
答案 0 :(得分:0)
以下代码将生成当前时间戳记的String对象(您可以将格式更改为所需的任何格式:
String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
现在,无论在何处生成范围报告,都可以在报告名称内传递此字符串。像这样:
extent = new ExtentReports (userDir +"\\test-output\\" + timeStamp + ".html", true);
加分点:
您还可以将功能名称添加到报告中,以实现更好的可访问性。您可以像这样在@Before
钩子中这样做:
@Before()
public void beforeScenario(Scenario scenario)
{
String fileName = scenario.getName() + "-" + timeStamp;
extent = new ExtentReports (userDir + \\test-output\\" + fileName+ ".html", true);
}
答案 1 :(得分:0)
很简单!!!!!!
在插件com.cucumber.listener.ExtentCucumberFormatter
中不要提及任何文件夹路径。
示例:
plugin = {
"pretty",
"html:FeaturesReport",
"html:target/site/cucumber-pretty",
"json:target/cucumber.json",
"com.cucumber.listener.ExtentCucumberFormatter:",
},
运行项目并刷新它
检查报告将在默认文件夹输出中生成/ Run_with系统时间/report.html
如果要在带有时间戳的指定路径中生成报告,请按照以下步骤操作。
goto maven依赖项
搜索cucumber-extentsreport.jar
扩展jar并选择com.cucumber.listener
程序包
复制ExtentProperties
类中的整个代码
紧紧放在包上,并创建名为ExtentProperties
然后将ExtentProperties
类代码粘贴到创建的枚举中
在下面的方法中搜索
ExtentProperties() {
this.reportPath = "output" + File.separator + "Run_" + System.currentTimeMillis() + File.separator + "report.html";
this.projectName = "default";
}
String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
String userDir = System.getProperty("user.dir");
ExtentProperties() {
this.reportPath = "Extent_Reports" + File.separator + "_" + timeStamp.replace(":","_").replace(".","_") + File.separator + "Execution report.html";
this.projectName = "default";
}
运行项目,然后刷新项目
检查报告将在名称指定的路径中生成
Extent_Reports / _2020_06_16_19_14_07 / Execution report.html
如有任何疑问,请发表评论