BeforeMethod failure is ignored

141 views
Skip to first unread message

Ankur Agrawal

unread,
Dec 30, 2009, 5:26:51 AM12/30/09
to testng...@googlegroups.com
Hi,
If the functionality inside the @BeforeMethod function fails then also testng continues to run Test method. Is it expected behavior by testng, if yes then why is it so ?

Then it means that there is no point of putting assertEquals(...) statements inside BeforeMethod functions.

One more observation is any assertEquals() fails inside BeforeMethod function then the failure message/exception doesn't come up on Console or any log file.
I am using Maven plugin of testng and observed that logs file shows assertEquals() failure exceptions of Test Methods only not of @BeforeMethod functions.

Thanks,
Ankur

Cédric Beust ♔

unread,
Dec 30, 2009, 3:31:21 PM12/30/09
to testng...@googlegroups.com
Hi Ankur,

You are right that there is a problem, but it seems to be just a logging bug:  TestNG is saying the tests passed while they actually got skipped.  This bug is only present in the text reporter (the one that displays the results in the console).

Can you confirm this?  Just put a breakpoint or a trace in one of your tests and confirm that it never gets called if a @BeforeMethod fails...

-- 
Cedric


--

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



--
Cédric


Ankur Agrawal

unread,
Jan 8, 2010, 3:15:55 AM1/8/10
to testng...@googlegroups.com
Hi Cedric:
Sorry for the delayed reply.
After some more debugging it was found that the problem was in our code not in Testng. Since we were using the Throwable catch statement with empty body, so the assertion failed exception caught by this catch block wasn't getting noticed by Testng and so the TC was passing.

I debugged what you said and found the testng functionality seems perfect.
When any configuring methods like @BeforeClass or @BeforeMethod are failed then is says configuration failure and when any test method fails then it says test failure which are expected also.

Thanks,
Ankur

2009/12/31 Cédric Beust ♔ <cbe...@google.com>
Reply all
Reply to author
Forward
0 new messages