TestNG suite means grouping two or more than two classes to
execute with a single command.
How to create:
Create some test class as I created below two test
class “FirstTest.java” and
“SecondTest.java” java files.
FirstTest.java:
import
org.testng.annotations.AfterClass;
import
org.testng.annotations.BeforeClass;
import
org.testng.annotations.Test;
public
class FirstTest {
@BeforeClass
public void beforeClass() {
System.out.println("One time executed before first mathod");
}
@AfterClass
public void afterClass() {
System.out.println("One time executed after last method");
}
@Test
public void testFirstMethod() {
System.out.println("@Test - executed first test method");
}
}
SecondTest.java
import
org.testng.annotations.AfterClass;
import
org.testng.annotations.BeforeClass;
import
org.testng.annotations.Test;
public
class SecondTest {
@BeforeClass
public void beforeClass() {
System.out.println("one time executed
before first mathod");
}
@AfterClass
public void afterClass() {
System.out.println("one time executed
after last method");
}
@Test
public void testSecondMethod() {
System.out.println("@Test - executed second test method");
}
}
Suite.xml file is suite file of above classes:
<!DOCTYPE
suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="TestNG Suite">
<test name="method">
<classes>
<class name="com.test.FirstTest" />
<class name="com.test.SecondTest" />
</classes>
</test>
</suite>
Run this suite file using TestNG, both test classes should be executed.
how to run the suite.xml file in eclipse
ReplyDeleteJust Right click on Suite.xml file on eclipse, you get TestNG option.
DeleteWOW just what I was searching for. Came here by searching for cellulite cream
ReplyDeleteHere is my web blog :: co zrobi䟺 cellulitem
can u please tell me , that how to use loop for tesing web application ?
ReplyDeletei have to create new user so every time i have to add values manually in selenium..so how can i use loop for that?