Continuous Test Orchestration And Execution Platform Online

Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.

How to run TestNG using the command prompt?

TestNG gives the facility to run tests using the command prompt. Here are the steps you can follow for the same:

  • Build distinct testing classes with distinct @Test methods.
  • Compile the class; an out folder will be created in IntelliJ, and a bin folder will be created in Eclipse.
  • Move all of the jar files to the lib folder.
  • Create the testng.xml file as shown below.
  • Launch cmd.
  • Using cd project <path>, navigate to the project path.
  • Execute the following command.
java -cp <path of lib>; <path of out or bin folder>
org.testng.TestNG <path of testng>/testng.xml

By giving the classpath for the JVM, the path to the compiled.class files, and the location of the TestNG XML configuration file; this program performs TestNG tests in Java. TestNG subsequently reads the configuration file, and the given tests are executed.

LambdaTest

Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.

Start Free Testing
LambdaTest

Earn resume-worthy Selenium certifications that help you land a top job.

Learn More
LambdaTest

Test your web or mobile apps

Test orchestration and execution cloud of 3000+ browsers and OS

Support

24/7 support

Security

Enterprise grade security

Cloud

Fastest test execution cloud