Test Logs in TestNG reports

6,222 views
Skip to first unread message

Nalin

unread,
Mar 31, 2009, 6:49:02 PM3/31/09
to testng-users
Hi,

Is it possible to get test logs in TestNG reports?

I am currently logging my test output using log4j to the console. Once
the test run finishes, TestNG reports only contain the exceptions for
failed tests. The test logs for passed test or logs up to the point of
exception for failed tests are lost.

Is there anyway of storing the complete logs? Will implementing
IListener or IReporter help?

Thanks.

Cosmin Marginean

unread,
Apr 1, 2009, 3:38:22 AM4/1/09
to testng...@googlegroups.com
I assume you can use Reporter.log(...). This will store the messages in
the TestNG log and are available in the HTML reports.
ITestListener and IReporter are mainly for handling test execution
status (onTestFailure, etc) or to generate a final report at the end of
the execution (IReporter), so in this case they probably won't help.
More about all of these here:
http://testng.org/doc/documentation-main.html#logging

Cosmin

Nalin

unread,
Apr 1, 2009, 1:42:04 PM4/1/09
to testng-users
After some snooping around I figured out the same. But I cant use
Reporter.log() because I need to ensure that tests and the execution
framework are loosely coupled.

I find it surprising that TestNG is not handling and storing the test
output to stdout. I think JUnit does that.

-nalin

Cédric Beust ♔

unread,
Apr 1, 2009, 1:55:24 PM4/1/09
to testng...@googlegroups.com
Hi Nalin,

The reasons why TestNG doesn't capture stdout/stderr are covered in this past discussion:


A typical way to do this is to set your own redirection in a @BeforeSuite method.  Would this work for you?

-- 
Cédric

loneranger

unread,
Apr 1, 2009, 2:22:03 PM4/1/09
to testng-users
if you are already using log4j to print stuff on console, why don't
you write custom log4j appender which internally calls reportng ? you
can even control it via log4j properties file and turn it on/off as
per your requirement.

On Apr 1, 10:55 am, Cédric Beust ♔ <cbe...@google.com> wrote:
> Hi Nalin,
> The reasons why TestNG doesn't capture stdout/stderr are covered in this
> past discussion:
>
> http://groups.google.com/group/testng-users/browse_thread/thread/ef2e...
>
> A typical way to do this is to set your own redirection in a @BeforeSuite
> method.  Would this work for you?
>
> --
> ***Cédric
> *

Nalin

unread,
Apr 4, 2009, 2:20:18 PM4/4/09
to testng-users
Cedric & Talik,

Thanks for the ideas. I'll give them a try and see what works
best.. :-)

-nalin

Dhanushka Kumara

unread,
Nov 6, 2017, 8:46:03 AM11/6/17
to testng-users
Hi,
Can you tell me how you add TestNG logs into log4j?
I'm tired of finding..
Reply all
Reply to author
Forward
0 new messages