import org.testng.annotations.*; class MyTest { @Test(dependsOnMethods = "beforeMethod") public void testFoo() throws Exception { } @Test(dependsOnMethods = "testFoo") public void testBar() {} @AfterSuite protected final void afterSuiteMethod() throws Throwable { } @BeforeMethod(dependsOnMethods = "afterSuiteMethod") public final void beforeMethod() throws Throwable { } @Test(dependsOnMethods = "foo*") public void testBar2() {} @Test(dependsOnMethods = "testBa*") public void testBar1() {} }