I am trying to run a Test method multiple times parallely using the testng @Dataprovider(parallel=true), and getting logging issue with that . Below is the code am referring to
public class simpletest3 {
public ExtentReports rep=ExtentManager.getInstance();
public ExtentTest test;
public Keywords app;
public String testName;
@Test(dataProvider="dta")
public void mytest(String uname,String pwd){
testName = "SamTest";
test = rep.createTest(testName);
System.out.println("Inside"+uname+pwd);
System.out.println(Thread.currentThread().getId());
test.info("Executing test Case with the data:: username ="+uname+" and the pwd = "+pwd);
}
@DataProvider(parallel=false)
public Object[][] dta(){
return new Object[][] { { "testuser_1", "Test@123" },
{ "testuser_2", "Test@456" },
{ "testuser_3", "Test@458" },
};
}
@AfterMethod
public void getResult(ITestResult result)
{
if(result.getStatus() == ITestResult.FAILURE)
{
test.log(Status.FAIL, MarkupHelper.createLabel(result.getName()+" Test case FAILED due to below issues:", ExtentColor.RED));
test.fail(result.getThrowable());
}
else if(result.getStatus() == ITestResult.SUCCESS)
{
test.log(Status.PASS, MarkupHelper.createLabel(result.getName()+" Test Case PASSED", ExtentColor.GREEN));
}
else
{
test.log(Status.SKIP, MarkupHelper.createLabel(result.getName()+" Test Case SKIPPED", ExtentColor.ORANGE));
test.skip(result.getThrowable());
}
}
@AfterTest
public void tearDown()
{
rep.flush();
}`
And am trying to create a extent instance as below
public static ExtentReports getInstance(){
Date d=new Date();
String fileName=d.toString().replace(":", "_").replace(" ", "_")+".html";
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(Constants.REPORT_PATH+fileName);
System.out.println(Constants.REPORT_PATH+fileName);
//extent = new ExtentReports(Constants.REPORT_PATH+fileName, true, DisplayOrder.NEWEST_FIRST);
extent = new ExtentReports();
extent.attachReporter(htmlReporter);
return extent;
}
Here i am trying to run a test method three times using the dataprovider. Issue is when i run the test parallely using parallel=true, the extent logging i am doing is getting recorded weirdly .In the attached image we can see logging for run instance 1 and 2 are recorded in report of test method instance 1, and run instance 3 logging is done in report of test method 2 and nothing is logged in the report of test method 3 and some times all the logging is happening in one single report of test method ( 1 or 2 or 3 not sure),
And when parallel=false , logging is happening correctly in each instance report is showing its own logging .
Attached the screenshots for the same . Need help
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/bc372a2f-5312-49a3-a794-3963a1538238%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/