I'm trying to create an Extent Report with several categories, this in combination with testng. But everytime I run several classes it will overwrite the last category and in the end I will only have the last category. Is there any way I can prevent this?
followin method is run in the @BeforeMethod and here I will init my test
private void setupReportBeforeTest(Method method){
Test test = method.getAnnotation(Test.class);
String author = "ABC";
String description = "Test";
try{
description = test.description().split(",author:")[0];
if (test.description().contains(",bug:")){
author = test.description().split(",author:")[1].split(",bug:")[0];
this.setJiraBug(test.description().split(",author:")[1].split(",bug:")[1]);
}else {
author = test.description().split(",author:")[1];
this.setJiraBug(null);
}
}catch (Exception e){ }
logging = extentReports.createTest(this.getTestName() + "-" + method.getName(),description)
.assignCategory(test.groups())
.assignAuthor(author).pass("Test");
}
I'm getting the groups information from the following:
@Test(groups = "Testgroup1",description = "Test1,author:Steve")
you may assign these Categories not in this setupReportBeforeTest() but in another function when tests are finished and you will have collected every groups in a table.
public void assign ( String[] testCategory)
reportTest.assignCategory(testCategory);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.