【发布时间】:2025-12-14 05:30:01
【问题描述】:
我使用的是 Extent Reports 3.1.5,我的报告在每次测试运行时都会被覆盖。我已尽我所能实施在堆栈溢出和各种站点上找到的解决方案,但没有任何进展。我花了 24 小时解决此问题并需要帮助。
我什至去检查了以下网站http://extentreports.com/docs/versions/3/java/#htmlreporter-features http://extentreports.com/docs/versions/3/java/#htmlreporter-features 并检查我的代码,仍然找不到问题。如果有什么我忽略了,请帮助我。
我的测试再次运行,但它只在我的 testng.xml 文件中写入最后一次运行的测试
这是我的基础测试类:
package test;
public class BaseTest {
//-------Page Objects----------
login_Page objBELogin;
poll_Page objCreatePoll;
survey_Page objCreateSurvey;
task_Page objCreateTaskGroup;
discussion_Page objCreateDiscussion;
userprofile_Page objUserProfile;
event_Page objectEvent;
workgroup_Page objectWorkgroup;
workroom_Page objectWorkroom;
//-----------------------------
static WebDriver driver;
static String homePage = "https://automation-ozzie.boardeffect.com/login";
ExtentReports report;
ExtentTest test;//--parent test
@BeforeClass
public void setUp() throws InterruptedException{
//--------Extent Report--------
report = ExtentFactory.getInstance();
//-----------------------------
System.setProperty("webdriver.chrome.driver","C:\\GRID\\chromedriver.exe");
ChromeOptions option = new ChromeOptions();
option.addArguments("disable-infobars");
driver = new ChromeDriver(option);
driver.manage().window().maximize();
driver.get(homePage);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@BeforeMethod
public void register(Method method) {
String testName = method.getName();
test = report.createTest(testName);
}
@AfterMethod
public void catureStatus(ITestResult result) {
if (result.getStatus()==ITestResult.SUCCESS) {
test.log(Status.PASS,"Test Method named as : "+ result.getName()+" is passed");
}else if(result.getStatus()==ITestResult.FAILURE) {
test.log(Status.PASS,"Test Method named as : "+ result.getName()+" is FAILED");
test.log(Status.FAIL,"Test failure : "+ result.getThrowable());
}
else if(result.getStatus()==ITestResult.SKIP) {
test.log(Status.PASS,"Test Method named as : "+ result.getName()+" is skipped");
}
}
@AfterClass
public void tearDown() throws InterruptedException {
report.flush();
driver.quit();
}
}
public class ExtentFactory {
public static ExtentReports getInstance() {
ExtentHtmlReporter html = new ExtentHtmlReporter("surefire-reports//Extent.html");
html.setAppendExisting(true);
ExtentReports extent = new ExtentReports();
extent.attachReporter(html);
return extent;
}
}
【问题讨论】:
标签: extentreports selenium-extent-report