- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我运行第一类时,结果会添加到报告中,但是当我运行第二类时,报告不会保留第一类的结果
//SimpleReportFactory {
package Rapport;
import com.relevantcodes.extentreports.DisplayOrder;
import com.relevantcodes.extentreports.ExtentReports;
public class SimpleReportFactory {
private static ExtentReports reporter;
public static synchronized ExtentReports getReporter() {
if (reporter == null) {
reporter = new ExtentReports("/Users/user/Desktop/untitled folder/SimpleReport3.html", true, DisplayOrder.NEWEST_FIRST);
}
return reporter;
}
public static synchronized void closeReporter() {
reporter.flush();
reporter.close();
}
}
//一级Test001
package Rapport;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.Test;
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;
public class Test001 {
private ExtentReports reporter = SimpleReportFactory.getReporter();
@Test
public void simpleTest002()
{
ExtentTest testReporter = reporter.startTest("simpleTest002", "This is a simple simpleTest002");
testReporter.log(LogStatus.INFO, "Starting test simpleTest002");
int a = 100;
int b = 30;
testReporter.log(LogStatus.INFO, "Loading the value of a to " + a);
testReporter.log(LogStatus.PASS, "Loading the value of b to " + b);
reporter.endTest(testReporter);
}
@AfterSuite
public void afterSuite()
{
reporter.close();
}
}
//第二类Test002
package Rapport;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.Test;
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;
public class Test002 {
private ExtentReports reporter = SimpleReportFactory.getReporter();
@Test
public void simpleTest004()
{
ExtentTest testReporter = reporter.startTest("simpleTest004", "This is a simple simpleTest004");
testReporter.log(LogStatus.INFO, "Starting test simpleTest004");
int a = 100;
int b = 30;
testReporter.log(LogStatus.INFO, "Loading the value of a to " + a);
testReporter.log(LogStatus.PASS, "Loading the value of b to " + b);
reporter.endTest(testReporter);
}
@AfterSuite
public void afterSuite()
{
reporter.close();
}
最佳答案
因为您正在使用
private ExtentReports reporter = SimpleReportFactory.getReporter();
两次;
对于 Extent 报告,如果您使用 ExtentReport 实例两次,则第一个实例的详细信息将被清除,它仅显示最后一个实例,在您的情况下,它仅显示第二个实例结果。
因此,尝试仅启动一次范围报告,然后在整个测试周期中使用此实例。
制作
ExtentReports reporter
实例全局且静态,然后使用此
reporter instance to the whole test cycle.
在测试执行最后关闭报告器实例。
关于java - 无法在 ExtentReport 中添加两个类的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36180844/
我有一个 Selenium/Java 项目,我们正在其中使用 ExtentReports。我们使用 PageFactory 模型,并有一个 BasePageFactory 负责所有测试准备工作。 Be
我正在使用范围报告通过页面对象模型为我的 Selenium 测试生成日志,并且我有单独的页面和测试类。我能够生成范围报告日志,但我的登录页面日志正在重复。我怀疑这是因为所有其他测试都使用了登录名,但我
目前我正在使用 ExtentReport 生成自动化报告。 我使用 ExtentReport 的方式是使用 IReporter 实现在测试结束时生成报告,这很棒。 但是,现在我正在考虑创建一种在执行测
我需要将所有跳过的测试用例添加到我的 ExtentReports 中。我怎样才能实现这个目标? 我在我的BaseTest.java中尝试了以下代码: @AfterMethod public void
当我运行第一类时,结果会添加到报告中,但是当我运行第二类时,报告不会保留第一类的结果 //SimpleReportFactory { package Rapport; import com.relev
我是新来的范围报告。我正在使用 Selenium Webdriver,并希望使用它的范围报告。 但是我的代码无法创建 ExtentReport 对象。 package com.code.draft;
我在调整 ExtentReports 以提供所需的输出时遇到了一些困难。 我有一个带有 TestNG 的简单测试框架,使用 TestBase 类来完成繁重的工作以保持测试简单。我希望以一种简单的方式实
我正在尝试将屏幕截图添加到我的 ExtentReport HTML 文件中,但由于某种原因,图像不存在,即使它确实存在并且控制台显示它正在查看正确的位置(href 是正确的)。 这是最新的试用代码:
有人可以告诉我如何编写结合 Selenium 页面对象模式和 ExtentsReports ( http://extentreports.relevantcodes.com/ ) 的功能性应用程序测试
我正在使用集成在一起的 tesng、extent-report 和 cucumber 构建新的自动化基础设施。使用以下代码。 @CucumberOptions(strict= false,
我正在尝试使用范围报告打印数组列表。但它给了我错误“ExtentTest 类型中的方法 log(LogStatus, Throwable) 不适用于参数 (LogStatus, ArrayList)”
我正在使用 Cucumber 和 TestNG 在移动设备上并行运行测试。下面给出了我的 TestNG 运行器类。 @CucumberOptions( features="src/te
我正在使用放心的库和范围报告进行报告, ValidatableResponse reponseManualLead = given().header("Accept", "application/js
我正在尝试自定义 ExtentReports 4.0.9当我在测试失败后打开报告时,它将屏幕截图显示为非常小的缩略图。如何增加缩略图的大小。 我尝试过extent-config.xml
社区大家好:我在尝试在 Cucumber 中实现范围报告时遇到了一些问题。 执行后我收到此问题: java.lang.IncompatibleClassChangeError: Implementin
我是测试新手,需要使用extentreports报告测试结果, 下面是测试代码: public ExtentReports reports; public ExtentTest logger; pub
我正在一台机器上运行 ThreadLocal 测试。我使用 @BeforeMethod 中的代码来启动网页。我还尝试过将其单独编写为我的 Base Test 类中的方法,并在 @BeforeMetho
我正在尝试使用 TestNG 中的 ExtentReports 准备测试执行报告。下面是我的代码- import org.openqa.selenium.By; import org.openqa.s
我正在寻找一种方法来实现高级范围报告,其中包含基本设置之外的测试步骤和结果数据。 我目前有一个可用的 ExtentReports 报告,并且正在寻找一种使用 ExtentReports (Logger
我有几个字段,我从 HTML 页面解析并添加到我的 report 中: extentTest.log(Status.INFO, String.format( "Add
我是一名优秀的程序员,十分优秀!