Using Reporter.log() in @AfterMethod

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

Using Reporter.log() in @AfterMethod

Sébastien Bouffard
Hello

I just noticed that when I use Reporter.log() in a method that is
annotated with @AfterMethod, the output will be written only in the
file "reporter-output.html".

It will not be written to the html report file of the test itself thus
it won't show up when clicking on the "Show all outputs" link for a
specific method. For the output to show there, you have to call
Reporter.log() from the test method itself, before @AfterMethod is
called.

Is this by design?

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: Using Reporter.log() in @AfterMethod

Cédric Beust ♔-2
Hi Sébastien,

Kind of. The logs are indexed by methods, and since the (current) reports only display the test methods in the main view, anything logged in a method that's not a test method won't appear there.

I agree it would make sense to add the logs for some configuration methods.

-- 
Cédric




2012/1/25 Sébastien Bouffard <[hidden email]>
Hello

I just noticed that when I use Reporter.log() in a method that is
annotated with @AfterMethod, the output will be written only in the
file "reporter-output.html".

It will not be written to the html report file of the test itself thus
it won't show up when clicking on the "Show all outputs" link for a
specific method. For the output to show there, you have to call
Reporter.log() from the test method itself, before @AfterMethod is
called.

Is this by design?

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Using Reporter.log() in @AfterMethod

MaC-41
Actually if @afterMethod failes the logs go to the report.

This is also a kind of show stopper for us right now, sine we are
using smth like this:

@AfterMethod(alwaysRun = true)
        protected void afterTest(final ITestResult result,
                        final ITestContext context) throws Exception {
                Reporter.log("IN AFTERMETHOD");
                if (!result.isSuccess() || result.getThrowable() != null) {

Reporter.log("TC X FAILED, see additional info in file Y");

} else {
Reporter.log("TC X PASSED");
}
}

But if there was no error nothing will be reported :(

I guess there is no workaround for this as of now?


THX and BR;

MaC



On 25 Jan., 20:44, Cédric Beust ♔ <[hidden email]> wrote:

> Hi Sébastien,
>
> Kind of. The logs are indexed by methods, and since the (current) reports
> only display the test methods in the main view, anything logged in a method
> that's not a test method won't appear there.
>
> I agree it would make sense to add the logs for some configuration methods.
>
> --
> Cédric
>
> 2012/1/25 Sébastien Bouffard <[hidden email]>
>
>
>
>
>
>
>
> > Hello
>
> > I just noticed that when I use Reporter.log() in a method that is
> > annotated with @AfterMethod, the output will be written only in the
> > file "reporter-output.html".
>
> > It will not be written to the html report file of the test itself thus
> > it won't show up when clicking on the "Show all outputs" link for a
> > specific method. For the output to show there, you have to call
> > Reporter.log() from the test method itself, before @AfterMethod is
> > called.
>
> > Is this by design?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "testng-users" group.
> > To post to this group, send email to [hidden email].
> > To unsubscribe from this group, send email to
> > [hidden email].
> > For more options, visit this group at
> >http://groups.google.com/group/testng-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: Using Reporter.log() in @AfterMethod

Arno Jost
In reply to this post by Cédric Beust ♔-2
Hi Cédric

The fact that i can't carry weight on the method-report in the @BeforeMethod and @AfterMethod bothers me too...

Strange enough, the "Method" object that can be passed to any method annotated with BeforeMethod or AfterMethod is allready holding the effective test-method.

So it seems the "m_currentTestResult" in the Reporter is perhaps just not the right fact to use as an log-index! ;-)

Greets,
Arno

Cedric Beust wrote
Hi Sébastien,

Kind of. The logs are indexed by methods, and since the (current) reports
only display the test methods in the main view, anything logged in a method
that's not a test method won't appear there.

I agree it would make sense to add the logs for some configuration methods.

--
Cédric




2012/1/25 Sébastien Bouffard <sebweb1010@gmail.com>

> Hello
>
> I just noticed that when I use Reporter.log() in a method that is
> annotated with @AfterMethod, the output will be written only in the
> file "reporter-output.html".
>
> It will not be written to the html report file of the test itself thus
> it won't show up when clicking on the "Show all outputs" link for a
> specific method. For the output to show there, you have to call
> Reporter.log() from the test method itself, before @AfterMethod is
> called.
>
> Is this by design?
>
> --
> You received this message because you are subscribed to the Google Groups
> "testng-users" group.
> To post to this group, send email to testng-users@googlegroups.com.
> To unsubscribe from this group, send email to
> testng-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/testng-users?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@googlegroups.com.
To unsubscribe from this group, send email to testng-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Using Reporter.log() in @AfterMethod

Abdullah Mohiuddin
In reply to this post by Cédric Beust ♔-2
Hi Cedric,

I am using testng-6.9.4.jar and I still see that Reporter.log() logs are showing in old reports but not in the new reports.  Has this been addressed yet or is it going to remain this way?  I really wanted testsOnly to be false or be able to be configured in xml Suite as parameter.
Is there any such option for me that I could use?  or is there a work around to get new reports show logs from non-test methods as well?

Thanks,
--Abdullah.

On Wednesday, January 25, 2012 at 1:44:02 PM UTC-6, Cédric Beust ♔ wrote:
Hi Sébastien,

Kind of. The logs are indexed by methods, and since the (current) reports only display the test methods in the main view, anything logged in a method that's not a test method won't appear there.

I agree it would make sense to add the logs for some configuration methods.

-- 
Cédric




2012/1/25 Sébastien Bouffard <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="K_q4le2r_0kJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">sebwe...@...>
Hello

I just noticed that when I use Reporter.log() in a method that is
annotated with @AfterMethod, the output will be written only in the
file "reporter-output.html".

It will not be written to the html report file of the test itself thus
it won't show up when clicking on the "Show all outputs" link for a
specific method. For the output to show there, you have to call
Reporter.log() from the test method itself, before @AfterMethod is
called.

Is this by design?

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="K_q4le2r_0kJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">testng...@....
To unsubscribe from this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="K_q4le2r_0kJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">testng-users...@googlegroups.com.
For more options, visit this group at <a href="http://groups.google.com/group/testng-users?hl=en" target="_blank" rel="nofollow" onmousedown="this.href='http://groups.google.com/group/testng-users?hl\75en';return true;" onclick="this.href='http://groups.google.com/group/testng-users?hl\75en';return true;">http://groups.google.com/group/testng-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-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].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using Reporter.log() in @AfterMethod

Abdullah Mohiuddin
Just to elaborate on this, I am not seeing any NullPointerException (NPE) but the generated reports only show logs from test methods only and none from BeforeMethod, BeforeClass, AfterMethod, AfterClass, (and possible DataProvider methos as well, haven't tried that).  Tried this using 6.8.21 as well as 6.9.4 versions of testng jars.
Appreciate it if you can shed some light on how to achieve this or if it needs a fix, when it will be fixed?

--Abdullah.


On Monday, July 6, 2015 at 1:02:05 PM UTC-5, Abdullah Mohiuddin wrote:
Hi Cedric,

I am using testng-6.9.4.jar and I still see that Reporter.log() logs are showing in old reports but not in the new reports.  Has this been addressed yet or is it going to remain this way?  I really wanted testsOnly to be false or be able to be configured in xml Suite as parameter.
Is there any such option for me that I could use?  or is there a work around to get new reports show logs from non-test methods as well?

Thanks,
--Abdullah.

On Wednesday, January 25, 2012 at 1:44:02 PM UTC-6, Cédric Beust ♔ wrote:
Hi Sébastien,

Kind of. The logs are indexed by methods, and since the (current) reports only display the test methods in the main view, anything logged in a method that's not a test method won't appear there.

I agree it would make sense to add the logs for some configuration methods.

-- 
Cédric




2012/1/25 Sébastien Bouffard <[hidden email]>
Hello

I just noticed that when I use Reporter.log() in a method that is
annotated with @AfterMethod, the output will be written only in the
file "reporter-output.html".

It will not be written to the html report file of the test itself thus
it won't show up when clicking on the "Show all outputs" link for a
specific method. For the output to show there, you have to call
Reporter.log() from the test method itself, before @AfterMethod is
called.

Is this by design?

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at <a href="http://groups.google.com/group/testng-users?hl=en" rel="nofollow" target="_blank" onmousedown="this.href='http://groups.google.com/group/testng-users?hl\75en';return true;" onclick="this.href='http://groups.google.com/group/testng-users?hl\75en';return true;">http://groups.google.com/group/testng-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-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].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using Reporter.log() in @AfterMethod

Shawn McCarthy-2
Reporter.log will not work correctly in AfterMethod or BeforeMethod. To get around this, I use onTestSuccess and onTestFailure, and onTestStart (from ITestListener - http://testng.org/javadoc/org/testng/ITestListener.html ). Reporter.log will work (as far as I have seen) from these methods.


On Monday, July 6, 2015 at 11:30:39 AM UTC-7, Abdullah Mohiuddin wrote:
Just to elaborate on this, I am not seeing any NullPointerException (NPE) but the generated reports only show logs from test methods only and none from BeforeMethod, BeforeClass, AfterMethod, AfterClass, (and possible DataProvider methos as well, haven't tried that).  Tried this using 6.8.21 as well as 6.9.4 versions of testng jars.
Appreciate it if you can shed some light on how to achieve this or if it needs a fix, when it will be fixed?

--Abdullah.


On Monday, July 6, 2015 at 1:02:05 PM UTC-5, Abdullah Mohiuddin wrote:
Hi Cedric,

I am using testng-6.9.4.jar and I still see that Reporter.log() logs are showing in old reports but not in the new reports.  Has this been addressed yet or is it going to remain this way?  I really wanted testsOnly to be false or be able to be configured in xml Suite as parameter.
Is there any such option for me that I could use?  or is there a work around to get new reports show logs from non-test methods as well?

Thanks,
--Abdullah.

On Wednesday, January 25, 2012 at 1:44:02 PM UTC-6, Cédric Beust ♔ wrote:
Hi Sébastien,

Kind of. The logs are indexed by methods, and since the (current) reports only display the test methods in the main view, anything logged in a method that's not a test method won't appear there.

I agree it would make sense to add the logs for some configuration methods.

-- 
Cédric




2012/1/25 Sébastien Bouffard <[hidden email]>
Hello

I just noticed that when I use Reporter.log() in a method that is
annotated with @AfterMethod, the output will be written only in the
file "reporter-output.html".

It will not be written to the html report file of the test itself thus
it won't show up when clicking on the "Show all outputs" link for a
specific method. For the output to show there, you have to call
Reporter.log() from the test method itself, before @AfterMethod is
called.

Is this by design?

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at <a href="http://groups.google.com/group/testng-users?hl=en" rel="nofollow" target="_blank" onmousedown="this.href='http://groups.google.com/group/testng-users?hl\75en';return true;" onclick="this.href='http://groups.google.com/group/testng-users?hl\75en';return true;">http://groups.google.com/group/testng-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "testng-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].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using Reporter.log() in @AfterMethod

Ibrahim Abedrabbo
In reply to this post by Sébastien Bouffard
I Found a way to use Reporter.log("s") in @AfterMethod annotated method. 

@AfterMethod
public void reportTest(ITestResult result) {
 
Reporter.setCurrentTestResult(result);
 
Reporter.log("Message");
}


The method will receive ITestResult runtime object for the test that has just finished.


On Wednesday, January 25, 2012 at 9:26:32 PM UTC+2, Sébastien Bouffard wrote:
Hello

I just noticed that when I use Reporter.log() in a method that is
annotated with @AfterMethod, the output will be written only in the
file "reporter-output.html".

It will not be written to the html report file of the test itself thus
it won't show up when clicking on the "Show all outputs" link for a
specific method. For the output to show there, you have to call
Reporter.log() from the test method itself, before @AfterMethod is
called.

Is this by design?

--
You received this message because you are subscribed to the Google Groups "testng-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].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Using Reporter.log() in @AfterMethod

sonal baghel
Thanks  Ibrahim , I tried it and working fine 



On Wednesday, January 18, 2017 at 6:41:53 PM UTC+5:30, Ibrahim Abedrabbo wrote:
I Found a way to use Reporter.log("s") in @AfterMethod annotated method. 

@AfterMethod
public void reportTest(ITestResult result) {
 
Reporter.setCurrentTestResult(result);
 
Reporter.log("Message");
}


The method will receive ITestResult runtime object for the test that has just finished.


On Wednesday, January 25, 2012 at 9:26:32 PM UTC+2, Sébastien Bouffard wrote:
Hello

I just noticed that when I use Reporter.log() in a method that is
annotated with @AfterMethod, the output will be written only in the
file "reporter-output.html".

It will not be written to the html report file of the test itself thus
it won't show up when clicking on the "Show all outputs" link for a
specific method. For the output to show there, you have to call
Reporter.log() from the test method itself, before @AfterMethod is
called.

Is this by design?

--
You received this message because you are subscribed to the Google Groups "testng-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].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.