In this post, we will see TestNG Parameters Annotation | Parameterizing from TestNG xml file | TestNG Parameterization
Program Code (Program1.java):
package mytest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class Program1 {
@Parameters({"url","key"})
@Test
public void AdmissionLogin(String myurl, String mykey)
{
System.out.println("Admission Login");//code for testcase
System.out.println(myurl);
System.out.println(mykey);
}
@Test
public void AdmissionBrokenlinks()
{
System.out.println("Admission Broken links"); //code for testcase
}
}
Program Code (Program2.java):
package mytest;
import org.testng.annotations.Test;
public class Program2 {
@Test(priority=2)
public void PlacementLogin()
{
System.out.println("Placement Login");//code for testcase
}
@Test(priority=3)
public void PlacementBrokenlinks()
{
System.out.println("Placement Broken links"); //code for testcase
}
@Test
public void FacultyLogin()
{
System.out.println("Faculty Login");//code for testcase
}
@Test(priority=1)
public void FacultyBrokenlinks()
{
System.out.println("Faculty Broken links"); //code for testcase
}
}
Program Code (testng.xml):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
<parameter name="url" value="www.comrevo.com"></parameter>
<parameter name="key" value="12345"></parameter>
<test name="College">
<classes>
<class name="mytest.Program1"></class>
<class name="mytest.Program2"></class>
</classes>
</test>
<test name="faculty">
<classes>
<class name="mytest.Program2"></class>
</classes>
</test>
</suite>
No comments:
Post a Comment