On Thu, May 9, 2013 at 2:23 PM, Mircea Markus <mmarkus(a)redhat.com> wrote:
On 9 May 2013, at 08:02, Dan Berindei wrote:
> Why would TestNG run an @AfterMethod method if the test didn't run?
if you set alwaysRun=true on that method it will run it disregarding if
the test was run or not.
> What method would it run after?
not sure i get the question.
A test method is "skipped" only if a dependency of the test failed (e.g.
a
@BeforeMethod method). A test that's in a different group may be considered
"ignored" or "disabled", but it's not "skipped". Since
TestNG is not even
trying to run the method, it shouldn't run any @BeforeMethod/@AfterMethod
methods for it either.
I wrote a test class with different groups for the test method and each
confguration method, and the only configuration methods that ran even with
no test method in the default group were @BeforeTest/@AfterTest.