log java exceptions to log4j

32 views
Skip to first unread message

Jonathan Aubuchon

unread,
Jun 30, 2015, 11:26:04 AM6/30/15
to cu...@googlegroups.com
Hi,

I'm trying to log the exceptions that are occuring during the execution of a test suite. Note that I also want the exceptions that are occurring during the @Before and @After hook.

From what I understand, cucumber print to the console those exceptions, but is there a way to log them into log4j?

PS: I don't want to place try{ ... } catch { logger.error(...) } in every steps.

Thank you

Björn Rasmusson

unread,
Jul 1, 2015, 7:33:03 AM7/1/15
to cu...@googlegroups.com
Jonathan Aubuchon wrote:
Hi,

I'm trying to log the exceptions that are occuring during the execution of a test suite. Note that I also want the exceptions that are occurring during the @Before and @After hook.

From what I understand, cucumber print to the console those exceptions, but is there a way to log them into log4j?

Hi,

Write your out custom formatter/reporter and use it to pass the exceptions to log4j, implementing the Reporter interface seems to be sufficient for this.
In the methods:
void before(Match match, Result result);

void result(Result result);

void after(Match match, Result result);

you can extract the exceptions from failed results and pass them to log4j.

Regards
Björn
 
Reply all
Reply to author
Forward
0 new messages