Issue with Extent reports , when trying to a test method parallely using data provider

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue with Extent reports , when trying to a test method parallely using data provider

naveen kumar-3

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 [hidden email].
To post to this group, send email to [hidden email].
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.

false_report.JPG (48K) Download Attachment
True_report.JPG (51K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Extent reports , when trying to a test method parallely using data provider

⇜Krishnan Mahadevan⇝
Pls help keep this forum relevant by posting queries that are related to selenium/WebDriver. 

I would suggest that you post your query on the extent reports forum. 

On Thu, Mar 22, 2018, 14:33 naveen kumar <[hidden email]> wrote:

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 [hidden email].
To post to this group, send email to [hidden email].
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/

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANikZLmNO%3DT7GGj_YCcyWG_Xdx3UaCe_xLwVZ0B3aSTE1zgLyw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Extent reports , when trying to a test method parallely using data provider

Magesh N
In reply to this post by naveen kumar-3
Replace the following line in your code:
        public ExtentTest test; by
    public ThreadLocal<ExtentTest> test;

On Thursday, March 22, 2018 at 2:33:23 PM UTC+5:30, naveen kumar wrote:

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());

<a href="http://test.info" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftest.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFIcPI_Lv00jVSuAcq6JTjpPJdzA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftest.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFIcPI_Lv00jVSuAcq6JTjpPJdzA&#39;;return true;" style="background-color: rgb(239, 240, 241);">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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/a32649ec-cfdc-45a9-8cc9-d41872f36394%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Extent reports , when trying to a test method parallely using data provider

naveen kumar-3
Thanks for the response Magesh. 

 if i use this
  public ThreadLocal<ExtentTest> test;

then i am getting the error at the line 

test=rep.createTest(testName);

and the error is "Type mismatch: cannot convert from ExtentTest to ThreadLocal<ExtentTest>" . And i am not cast this even 

Thanks
Naveen

On Thursday, March 22, 2018 at 3:29:20 PM UTC+5:30, Magesh N wrote:
Replace the following line in your code:
        public ExtentTest test; by
    public ThreadLocal<ExtentTest> test;

On Thursday, March 22, 2018 at 2:33:23 PM UTC+5:30, naveen kumar wrote:

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());

<a href="http://test.info" rel="nofollow" style="background-color:rgb(239,240,241)" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftest.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFIcPI_Lv00jVSuAcq6JTjpPJdzA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftest.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFIcPI_Lv00jVSuAcq6JTjpPJdzA&#39;;return true;">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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/eec689ee-96b1-4c54-91ae-fba5935ab87e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Extent reports , when trying to a test method parallely using data provider

M.R Chaudhary
In reply to this post by naveen kumar-3
Can someone please solve this issue, i am also facing same error if using localthread, and without localthread report is not correct. What i noticed is with parallel execution default testng report is working perfectly but extent report have issue.

On Thursday, 22 March 2018 12:03:23 UTC+3, naveen kumar wrote:

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());

<a href="http://test.info" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftest.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFIcPI_Lv00jVSuAcq6JTjpPJdzA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftest.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGFIcPI_Lv00jVSuAcq6JTjpPJdzA&#39;;return true;">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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/d6688bd9-1b27-48ee-a72d-4db00ecf3595%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.