Thursday, June 12, 2014

Groupstest On Class And Method

package GroupsOnClassAndMethod;

import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;

public class TestGroup {

@BeforeGroups("database")
public void setupDB() {
System.out.println("setupDB()");
}

@AfterGroups("database")
public void cleanDB() {
System.out.println("cleanDB()");
}

@Test(groups= "selenium-test")
public void runSelenium() {
System.out.println("runSelenium()");
}

@Test(groups= "selenium-test")
public void runSelenium1() {
System.out.println("runSelenium()1");
}

@Test(groups = "database")
public void testConnectOracle() {
System.out.println("testConnectOracle()");
}

@Test(groups = "database")
public void testConnectMsSQL() {
System.out.println("testConnectMsSQL");
}

@Test(dependsOnGroups = {"database","selenium-test"})
public void runFinal() {
System.out.println("runFinal");
}

}


package GroupsOnClassAndMethod;

import org.testng.annotations.Test;

@Test(groups= "selenium-test")
public class TestSelenium {

public void runSelenium() {
System.out.println("runSelenium()");
}

public void runSelenium1() {
System.out.println("runSelenium()1");
}

}


<suite name="TestAll">

<test name="final">
<classes>
<class name="GroupsOnClassAndMethod.TestSelenium" />
<class name="GroupsOnClassAndMethod.TestGroup" />
</classes>
</test>

<!-- Run test method on group "selenium" only -->
<test name="selenium">

<groups>
<run>
<include name="selenium-test" />
</run>
</groups>

<classes>
<class name="GroupsOnClassAndMethod.TestSelenium" />
<class name="GroupsOnClassAndMethod.TestGroup" />
</classes>

</test>

</suite>

No comments:

Post a Comment