扩展报告在HTMLReport中不以“失败”状态显示测试。我已经使用了test.log(LogStatus.PASS)和test.log(LogStatus.FAIL)仍然以某种方式未记录失败状态。通过的测试将正确地映射到报告中,但是失败的将与结果一起捕获。
下面是测试类代码:
@Test(priority=1)
public void TestCaseMethod() throws Exception {
try {
test=extent.startTest("CustomerPortal:EditAccountDetails");
ClassOne TS1 = new ClassOne(driver,wait);
TS1.Method1();
ClassTwo TS2 = new ClassTwo(driver,wait);
TS2.logintoportal();
ClassThree TS3 = new ClassThree(driver,wait);
TS3.EditAccountDetails();
test.log(LogStatus.PASS, "CustomerPortal:EditAccountDetails Test Case
Passed.");
}
catch(Exception e) {
Assert.fail(e.getMessage());
test.log(LogStatus.FAIL, "CustomerPortal:EditAccountDetails Test Case
Failed.");
}
finally {
TakeScreenshotMethod();
extent.endTest(test);
}
}
以下分别是BeforeSuite和AfterSuite中的代码:
@BeforeSuite
public void initializetest() throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\kovid.anil.mehta\\Downloads\\chromedriver_win32\\chromedriver.exe");
extent = new ExtentReports("C:\\Users\\kovid.anil.mehta\\RegressionSuite\\test-output\\reportextent.html", true);
extent.loadConfig(new File("C:\\Users\\kovid.anil.mehta\\RegressionSuite\\ExtentReportConfig.xml"));
extent.startTest(this.getClass().getName());
ChromeOptions option = new ChromeOptions();
option.addArguments("start-maximized");
option.setHeadless(true);
driver =new ChromeDriver(option);
wait = new WebDriverWait(driver,30);
driver.get("SomeWebsite.com");
driver.findElement(username).sendKeys("user@name.com");
driver.findElement(password).sendKeys("Fancy@password");
driver.findElement(LoginButton).click();
Thread.sleep(10000);
}
@AfterSuite(alwaysRun=true)
public void endTest() throws IOException, Exception {
extent.flush();
extent.endTest(test);
Thread.sleep(5000);
driver.quit();
driver=null;
}
Extent Report Dependency :
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
我希望在报告中针对失败的测试案例正确映射结果。