This is an exploration of the precedence order for TestNG annotations so I can get a better understanding of which annotations come first.
As we can see in testOutput.log
, there is a clear order to these methods (I wish they put that order more clearly in the TestNG Documentation...
The original question was "What is the difference between @BeforeMethod
and @BeforeTest
?" After seeing the results, it's clear that @BeforeMethod
refers to each individual @Test
annotated method, while @Test
refers to the <test>
organizational blocks in the testng.xml
test suite file.
One thing that confused me is that @BeforeGroups
and @AfterGroups
both needed to be supplied with their groups, when I originally thought they would automatically run before all groups. It does make sense though, once I found out what was going on.
Another interesting thing is I think I found an IntelliJ TestNG integration bug where running a Groups test fails because the parallel
attribute for the test suite isn't set.