Next-Gen App & Browser
Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud

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.

Test Your Website on 3000+ Browsers

Get 100 minutes of automation test minutes FREE!!

Test Now...

KaneAI - Testing Assistant

World’s first AI-Native E2E testing agent.

...
ShadowLT Logo

Start your journey with LambdaTest

Get 100 minutes of automation test minutes FREE!!

Signup for free