-
Notifications
You must be signed in to change notification settings - Fork 1k
Issue549: Groups in @BeforeMethod and @AfterMethod don't work as expected
This wiki page is to explain the Issue 549.
https://github.com/wengm/testng-training/blob/master/basic/src/test/java/org/testng/forum/i549/Test549.java https://github.com/wengm/testng-training/blob/master/basic/src/suites/forum/i549.xml
6.10 - 7.0.0-beta7
beforeTc1(), afterTc1() are not executed at all because it belongs to the group S1 and the test method testTc1 belong to that group is not executed at all.
The Javadoc of the groups attribute says: 6.10:
/** * The list of groups this class/method belongs to. */
7.0.0-beta7:
/** * The list of groups this class/method belongs to. Note that even if the test method being * invoked belongs to a different group, all @BeforeMethod methods will be invoked before it as * long as they belong to groups that were selected to run at all. See {@link #onlyForGroups()} to * select test method groups which this method will be invoked before. */
The Javadoc in 7.0.0-beta7 is still a bit confused. However, if let me guess, it means as long as the groups to which the @BeforeMethod belongs is selected to run, the @BeforeMethod will run for all test methods.
Even the test methods of the group in the attribute groups is NOT selectd to run, @BeforeMethod belong that group still run.
From 7.0.0-beta7, Use onlyForGroups attribute if you want Before and After methods only run for the specific test method.