My reading of the TestNG docs suggests that if I have a test method marked like this:
@BeforeSuite(alwaysRun = true)
@Test
public void MyTestMethod { ... }
then MyTestMethod
would run before any other test defined anywhere, regardless of class, suite or group. But that does not seem to be the case.
Is there a way to make a test method run unconditionally before everything else? (And that if it fails no other tests will be run.)
Edit:
The test class:
class Suite_Setup
extends BaseTestSuite
{
@BeforeSuite(alwaysRun = true)
def setup() {
System.out.println("Conducting test suite setup...")
// Verify that the internal API is configured properly and that the API host is available...
new Action(ApiHostname, new BasicCookieStore)
}
}
Edit:
The answer:
We generate our own TestNG.xml files (automatically) and the @BeforeSuite method was not being included in it. Once it was included, @BeforeSuite
had the expected effect.
However, it does appear that both @BeforeSuite
(and presumably other @Before...
and @After...
annotations) can be mixed with @Test
and rather than inhibiting the execution of the annotated method, they cause it to run more than once!
Also, I remiss in not indicating which version of TestNG I'm using. It's 6.2.