I am executing my selenium automation scripts through testng, for the same I am having a testng xml form where I am passing parameter values like which test case has to be executed and on which environment it has to be executed.
E.g of testng xml is pasted below
**<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Automation Suite">
<parameter name="tags" value="MyTestCase"/>
<!-- Default suite -->
<test name="GGGGG Automation Test" verbose="2">
<parameter name="Environment" value="MyEnvironment" />
<classes>
<class name="com.XXXXX.TestRunner.XXXXXX"/>
</classes>
</test>
</suite>**
here I am passing 2 parameters like test cases and environment to be executed form testng example. I am looking for a command line 'command' to execute the testng xml passing those 2 parameters from commandline argument.
By using JVM arguments you can pass in parameters, such as -Dname=Environment. This has been answered previously here.
Hi Thanks a lot for your response. I already seen this method, it is given for the maven. I am not using maven in my project. Do you have any alternate solution for this without using maven. My TestNG command line looks like this "java -cp lib*;bin org.testng.TestNG -DEnvironment="QA" TestNGRunner.xml"
@Shyam - Irrespective of whether you use Maven or not, the approach is the same.
Its working fine, I was trying without removing the @Parameter tag. after removing it, it is working fine