Create and Execute TesNG.XML file
Let us now create our first test case
import org.testng.Assert;
import org.testng.annotations.Test;
public class TestNGExample{
@Test
Public void TestNGSample(){
System.out.println(“This is my Frist TestNG programme”)
}
}
How to Generate TestNG XML file
Make sure that TestNG jar files should be associated to your project
Right-click on the your project(TestNGExample)and select TestNG | Convert to TestNG.
Eclipse will create testng.xml which says that you need to run only one test with the name NewTest as shown in the following screenshot:
Then click on Next button then Finish Button
Sample TestNG.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none">
<test name="Test">
<classes>
<class name="TestNGExample"/>
</classes>
</test><!-- Test -->
</suite><!-- Suite -->
Now you need to run test through this testng.xml.
Results
How to Run TestNG.xml file through Command Prompt
Use below one for run
java -cp "E:\selenium\workspace\TestNHExampels\bin;E:\software\selenium\testng-6.8\testng-6.8.jar" org.testng.TestNG testng.xml
E:\selenium\workspace\TestNHExampels\bin-à Where your java class files are storing
E:\software\selenium\testng-6.8à Where Your testng jar file is located
Results
Comments
Post a Comment