In this post, we will see How To Run Test Cases in TestNG from xml File | Basic Structure of testng.xml file in TestNG
Program Code (Program1.java):
package mytest;
import org.testng.annotations.Test;
public class Program1 {
@Test
public void testcase1()
{
System.out.println("In test case 1");//code for testcase
}
@Test
public void testcase2()
{
System.out.println("In test case 2"); //code for testcase
}
}
Program Code (Program2.java):
package mytest;
import org.testng.annotations.Test;
public class Program2 {
@Test
public void testcase3()
{
System.out.println("In test case 3");//code for testcase
}
@Test
public void testcase4()
{
System.out.println("In test case 4"); //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">
<test thread-count="5" name="Test">
<classes>
<class name="mytest.Program2"/>
<class name="mytest.Program1"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
Watch following video:
Watch on YouTube: https://www.youtube.com/watch?v=uCnQgvv0Rbg
No comments:
Post a Comment