Thursday, June 12, 2014

TestSuite

package TestSuite;

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 TestSuite;

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 TestSuite;

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");
}

}


<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="TestAll">

<test name="order">
<classes>
<class name="TestSuite.TestConfig" />
<class name="TestSuite.TestOrder" />
</classes>
</test>

<test name="database">
<classes>
<class name="TestSuite.TestConfig" />
<class name="TestSuite.TestDatabase" />
</classes>
</test>

</suite>

No comments:

Post a Comment