- @BeforeSuite
- @BeforeTest
- @BeforeClass
- @BeforeMethod
- @Test
- @AfterMethod
- @AfterClass
- @AfterTest
- @AfterSuite
package testNGPackage;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class TestNGAnnotaions {
@BeforeSuite
public void testsuite() {
System.out.println("This is before suite");
}
@BeforeTest
public void beofretest() {
System.out.println("This is before test");
}
@BeforeClass
public void beofreclass() {
System.out.println("This is before Class ");
}
@BeforeMethod
public void beofremethod() {
System.out.println("This is before method ");
}
@Test
public void testmetnod() {
System.out.println("This is Test Method");
}
@AfterMethod
public void aftermethod() {
System.out.println("This is after Method ");
}
@AfterClass
public void afterclass() {
System.out.println("This is after Class ");
}
@AfterTest
public void aftertest() {
System.out.println("This is after Test ");
}
@AfterSuite
public void aftersuite() {
System.out.println("This is after suite ");
}
}
package testNGPackage;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class TestNGAnnotaions {
@Test
public void testmetnod() {
System.out.println("This is Test Method");
}
@BeforeSuite
public void beforesuite() {
System.out.println("This is before suite");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="User Login Details">
<test name="userSignup">
<classes>
<class name="testNGPackage.FirstTestngClass"/>
<class name="testNGPackage.SecondTestngClass"/>
</classes>
</test> <!-- Test -->
<test name="Vendorsignup">
<classes>
<class name="testNGPackage.TestNGAnnotaions"/>
<class name="testNGPackage.ThirdTestNGClass"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
package testNGPackage;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class TestNGAnnotaions {
@Test
public void testmetnod() {
System.out.println("This is Test Method");
}
@BeforeTest
public void beforemethod() {
System.out.println("This is before method");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="User Login Details">
<test name="userSignup">
<classes>
<class name="testNGPackage.FirstTestngClass"/>
<class name="testNGPackage.SecondTestngClass"/>
</classes>
</test> <!-- Test -->
<test name="Vendorsignup">
<classes>
<class name="testNGPackage.TestNGAnnotaions"/>
<class name="testNGPackage.ThirdTestNGClass"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
package testNGPackage;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class TestNGAnnotaions {
@Test
public void testmetnod() {
System.out.println("This is Test Method");
}
@BeforeClass
public void beforeclass() {
System.out.println("This is before Class ");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="User Login Details">
<test name="userSignup">
<classes>
<class name="testNGPackage.FirstTestngClass"/>
<class name="testNGPackage.SecondTestngClass"/>
</classes>
</test> <!-- Test -->
<test name="Vendorsignup">
<classes>
<class name="testNGPackage.TestNGAnnotaions"/>
<class name="testNGPackage.ThirdTestNGClass"/>
</classes>
</test> <!-- Test -->
</suite
> <!-- Suite -->
@BeforeMethod
package testNGPackage;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class TestNGAnnotaions {
@Test
public void testmetnod() {
System.out.println("This is Test Method");
}
@BeforeMethod
public void beforemethod() {
System.out.println("This is Before method");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="User Login Details">
<test name="userSignup">
<classes>
<class name="testNGPackage.FirstTestngClass"/>
<class name="testNGPackage.SecondTestngClass"/>
</classes>
</test> <!-- Test -->
<test name="Vendorsignup">
<classes>
<class name="testNGPackage.TestNGAnnotaions"/>
<class name="testNGPackage.ThirdTestNGClass"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
@AfterMethod
package testNGPackage;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class TestNGAnnotaions {
@Test
public void testmetnod() {
System.out.println("This is Test Method");
}
@Test
public void seconfmethod() {
System.out.println("This is second Method");
}
@AfterMethod
public void Aftermethod() {
System.out.println("This is After method");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="User Login Details">
<test name="userSignup">
<classes>
<class name="testNGPackage.FirstTestngClass"/>
<class name="testNGPackage.SecondTestngClass"/>
</classes>
</test> <!-- Test -->
<test name="Vendorsignup">
<classes>
<class name="testNGPackage.TestNGAnnotaions"/>
<class name="testNGPackage.ThirdTestNGClass"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
package testNGPackage;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class TestNGAnnotaions {
@Test
public void testmetnod() {
System.out.println("This is Test Method");
}
@AfterClass
public void afterclass() {
System.out.println("This is after Class ");
}
}
XML File
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="User Login Details">
<test name="userSignup">
<classes>
<class name="testNGPackage.FirstTestngClass"/>
<class name="testNGPackage.SecondTestngClass"/>
</classes>
</test> <!-- Test -->
<test name="Vendorsignup">
<classes>
<class name="testNGPackage.TestNGAnnotaions"/>
<class name="testNGPackage.ThirdTestNGClass"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
package testNGPackage;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class TestNGAnnotaions {
@Test
public void testmetnod() {
System.out.println("This is Test Method");
}
@AfterTest
public void aftertest() {
System.out.println("This is after method");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="User Login Details">
<test name="userSignup">
<classes>
<class name="testNGPackage.FirstTestngClass"/>
<class name="testNGPackage.SecondTestngClass"/>
</classes>
</test> <!-- Test -->
<test name="Vendorsignup">
<classes>
<class name="testNGPackage.TestNGAnnotaions"/>
<class name="testNGPackage.ThirdTestNGClass"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
package testNGPackage;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class TestNGAnnotaions {
@Test
public void testmetnod() {
System.out.println("This is Test Method");
}
@AfterSuite
public void aftersuite() {
System.out.println("This is After suite");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="User Login Details">
<test name="userSignup">
<classes>
<class name="testNGPackage.FirstTestngClass"/>
<class name="testNGPackage.SecondTestngClass"/>
</classes>
</test> <!-- Test -->
<test name="Vendorsignup">
<classes>
<class name="testNGPackage.TestNGAnnotaions"/>
<class name="testNGPackage.ThirdTestNGClass"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
0 Comments