我正在当前项目中研究范围报告框架。在我的测试类中,我使用 Data-provider 类来导入测试数据。特定测试包含 10 个验证测试迭代数据提供者键。当涉及范围报告时,我将方法名称写入报告但我必须区分每个数据提供者测试,并使用与每个验证测试匹配的名称。这是我的脚本:1。范围报告配置:
@BeforeSuite
public void setUp()
{
htmlReporter = new ExtentHtmlReporter(System.getProperty("user.dir") +"/test-output/extentReport.html");
extent = new ExtentReports();
extent.attachReporter(htmlReporter);
extent.setSystemInfo("OS", "Windows");
extent.setSystemInfo("Host Name", "1016086");
extent.setSystemInfo("Environment", "QA");
extent.setSystemInfo("User Name", "BABURAJ V D");
htmlReporter.config().setChartVisibilityOnOpen(true);
htmlReporter.config().setDocumentTitle("Extent report");
htmlReporter.config().setReportName("Final Report");
}
@BeforeClass
public synchronized void beforeClass() {
test = extent.createTest(getClass().getSimpleName());
parentTest.set(test);
}
@BeforeMethod
public synchronized void beforeMethod(Method method) {
child = parentTest.get().createNode(method.getName());
childTest.set(child);
}
@AfterMethod
public synchronized void afterMethod(ITestResult result) {
if (result.getStatus() == ITestResult.FAILURE)
childTest.get().fail(result.getThrowable());
else if (result.getStatus() == ITestResult.SKIP)
childTest.get().skip(result.getThrowable());
else
childTest.get().pass("Test passed");
}
@AfterSuite
public void tearDown(){
extent.flush();
}
@Test(priority = 2, dataProvider = GE_XR240_DEVICE_DataProvider.DEVICE_ADD_VALIDATIONS, dataProviderClass = GE_XR240_DEVICE_DataProvider.class)
public void OPTIMA_XR240_FAILED_MESSAGE_VALIDATION(Map<String, String> deviceTestData) throws InterruptedException { }
这些是在特定测试 OPTIMA_XR240_FAILED_MESSAGE_VALIDATION 中发生的验证或应该在 UI 中显示的错误消息:
Add Device Failed - System name should be filled
Add Device Failed - System Id should be filled
Add Device Failed - Manufacturer should be assigned
Add Device Failed - System model should be assigned
Add Device Failed - Current IP Address / Host Name should be filled
所以我制作的报告应该包含一条与其执行的验证相关的信息,而不仅仅是方法名称。