<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 9, 2013 at 2:23 PM, Mircea Markus <span dir="ltr"><<a href="mailto:mmarkus@redhat.com" target="_blank">mmarkus@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On 9 May 2013, at 08:02, Dan Berindei wrote:<br>
<br>
> Why would TestNG run an @AfterMethod method if the test didn't run?<br>
</div>if you set alwaysRun=true on that method it will run it disregarding if the test was run or not.<br>
<div class="im">> What method would it run after?<br>
</div>not sure i get the question.<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote></div><br></div>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.<br>
<div class="gmail_extra"><br></div><div class="gmail_extra">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.<br>
<br></div></div>