package GroupIncludeOrExclude;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
//show the use of @BeforeSuite and @BeforeTest
public class TestConfig {
@BeforeSuite
public void testBeforeSuite() {
System.out.println("testBeforeSuite()");
}
@AfterSuite
public void testAfterSuite() {
System.out.println("testAfterSuite()");
}
@BeforeTest
public void testBeforeTest() {
System.out.println("testBeforeTest()");
}
@AfterTest
public void testAfterTest() {
System.out.println("testAfterTest()");
}
}
package GroupIncludeOrExclude;
import org.testng.annotations.Test;
public class TestDatabase {
@Test(groups = "db")
public void testConnectOracle() {
System.out.println("testConnectOracle()");
}
@Test(groups = "db")
public void testConnectMsSQL() {
System.out.println("testConnectMsSQL");
}
@Test(groups = "db-nosql")
public void testConnectMongoDB() {
System.out.println("testConnectMongoDB");
}
@Test(groups = { "db", "brokenTests" })
public void testConnectMySQL() {
System.out.println("testConnectMySQL");
}
}
package GroupIncludeOrExclude;
import org.testng.annotations.Test;
public class TestOrder {
@Test(groups={"orderBo", "save"})
public void testMakeOrder() {
System.out.println("testMakeOrder");
}
@Test(groups={"orderBo", "save"})
public void testMakeEmptyOrder() {
System.out.println("testMakeEmptyOrder");
}
@Test(groups="orderBo")
public void testUpdateOrder() {
System.out.println("testUpdateOrder");
}
@Test(groups="orderBo")
public void testFindOrder() {
System.out.println("testFindOrder");
}
}
<suite name="TestAll">
<test name="database">
<groups>
<run>
<exclude name="brokenTests" />
<include name="db" />
</run>
</groups>
<classes>
<class name="GroupIncludeOrExclude.TestDatabase" />
<class name="GroupIncludeOrExclude.TestConfig" />
</classes>
</test>
</suite>
No comments:
Post a Comment