I am trying to debug a TESTNG test using Debug Configurations option in Eclipse and I need to get the Program arguments inside my TestNG test. Could you please help me in accomplishing it?
You can pass values to TestNG via two means in the Run Configurations screen
The below sample shows how to read those values from the Run configuration
import org.testng.annotations.Test;
public class HelloWorldTestClass {
@Test
public void testMethod() {
//This is how we read values provided via the Environment tab section of the run configuration.
String environment = System.getenv("env");
//This is how we read values provided via the VM arguments section
String browser = System.getProperty("browser");
System.err.println("Running on [" + browser + "] in the environment [" + environment + "]");
}
}
Below is the output of the execution:
[RemoteTestNG] detected TestNG version 6.14.3
Running on [Opera] in the environment [Production]
PASSED: testMethod
===============================================
Default test
Tests run: 1, Failures: 0, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 0, Skips: 0
===============================================