TestNG Annotations Attributes in Selenium With Example
TestNG Annotations Helper Attributes Syntax
The basic syntax of testing the annotations attribute is given below.@Test(attribute="value")
public void testcase2()
{
System.out.println("This is testcase2");
}
- description
- timeOut
- priority
- dependsOnMethods
- enabled
- groups
package testNGpackage;
import org.testng.annotations.Test;
public class FirstTestNGprogram {
@Test(description="This is testcase1")
public void userlogin()
{
System.out.println("This is user Login");
}
@Test (description="This is testcase2")
public void cutomerlogin()
{
System.out.println("This is cutomer Login");
}
}
package testNGPackage;
import org.testng.annotations.Test;
public class FirstTestngClass {
@Test
public void usersignup() {
System.out.println("user Signup");
}
@Test
public void membersingup() {
System.out.println("This is Member singup");
}
@Test
public void customersingup() {
System.out.println("This Customer signup");
}
@Test (timeOut=4000)
public void customerdetails() {
System.out.println("This Customer Details");
}
}
- priority
- dependsOnMethods
package testNGPackage;
import org.testng.annotations.Test;
public class FirstTestngClass {
@Test
public void usersignup() {
System.out.println("user Signup");
}
@Test
public void membersingup() {
System.out.println("This is Member singup");
}
@Test
public void customersingup() {
System.out.println("This Customer signup");
}
@Test (enabled=false)
public void customerdetails() {
System.out.println("This Customer Details");
}
}
package testNGPackage;
import org.testng.annotations.Test;
public class FirstTestngClass {
@Test
public void usersignup() {
System.out.println("user Signup");
}
@Test
public void membersingup() {
System.out.println("This is Member singup");
}
@Test(groups={"signup"})
public void customersingup() {
System.out.println("This Customer signup");
}
@Test
public void customerdetails() {
System.out.println("This Customer Details");
}
}
package testNGPackage;
import org.testng.annotations.Test;
public class SecondTestngClass {
@Test
public void usersignin() {
System.out.println("user Sign in");
}
@Test(groups={"signup"})
public void membersingin() {
System.out.println("This is Member singin");
}
@Test
public void customersingin() {
System.out.println("This Customer signin");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test name="userSignup">
<groups>
<run>
<include name="signup"></include>
</run>
</groups>
<classes>
<class name="testNGPackage.FirstTestngClass"/>
<class name="testNGPackage.SecondTestngClass"/>
</classes>
0 Comments