Friday, April 16, 2021

Run testng tests from maven cmd






1. How to run testng tests from maven cmd


Prerequisite for Java
1. Java should be installed on your system.
2. Eclipse should be available.
3. Maven Java project should be created.

Prerequisite for TestNG
1. TestNG plugin should be added in eclipse IDE.
2. TestNG dependency should be added in pom.xml
3. TestNG tests should be created in your project.
4. testng.xml file should be created.

Prerequisite for Maven
1. Maven should be installed on your system.
2. Download maven https://maven.apache.org/download.cgi
3. Add maven to environment variables in your system.
4. Run the below command to check maven version

Command : mvn -version



How to run testng from maven command line

Step 1. Add maven surefire plugin in pom.xml
https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin/2.19.1

Step 2. Provide location of your testng.xml file
/ProjectName/testng.xml

Also you can provide complete path
C:\Users\Username\eclipse-workspace_API\projectName\testng.xml

Step 3. Open cmd and go to location of project

Step 4. Run commands
mvn clean
mvn install
mvn test
 or you can only run command 
mvn clean test

Step 4: It will start executing the maven command



How to provide testng.xml file name at runtime






















No comments:

Post a Comment

How to install Java on EC2

***************************************** How to install Java on EC2 ***************************************** To be continued, In this post...

All Time Popular Post