'How to run testNG xml in a maven project without using surefire plugin with command prompt?

I am trying to run testng.xml in a maven project as part of selenium automation testing using the command line in windows. Able to execute testng.xml from the command prompt using java org.testng.TestNG testng.xml command when it is a Java project. But my requirement is to execute testng.xml in a Maven project using the command line. I understood that this can be achieved using surefire plugin but due to workplace-related restrictions, I am not permitted to add this plugin in pom.xml.

I tried to execute testng.xml in maven project as like in a java project and also mentioned all required folders and paths (including target/classes and target/test-classes folders in maven project) in classpath using -cp yet command line thrown error stating Cannot find class in classpath: <packagename>.<classname>. Kindly suggest.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source