Reputation: 1
To run testng test from command prompt i have to set the class path and run tests C:\newworkspace\SeleniumSample>set classpath = C:\newworkspace\SeleniumSample\bin; C:\newworkspace\SeleniumSample\lib*
C:\newworkspace\SeleniumSample>java org.testng.TestNG testng.xml
My maven project doesn't contain bin or lib folders.I manually created lib folder and added jars to this folder.Any help would be great.
Upvotes: 0
Views: 1690
Reputation: 3776
Maven does not have a bin folder as all the dependent JAR files mentioned in the POM file are downloaded and saved in the ${user.home}/.m2 folder. If you want to trigger TestNG Test case from command line you can use the Maven Surefire plugin for TestNG by configuring the plugin in POM.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<failIfNoTests>true</failIfNoTests>
<skipTests>false</skipTests>
<suiteXmlFiles>
<suiteXmlFile>${testNGXMLFile}</suiteXmlFile>
</suiteXmlFiles>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>true</value>
</property>
</properties>
<workingDirectory>${basedir}</workingDirectory>
</configuration>
</plugin>
</plugins>
</build>
Then from the command prompt you can trigger using maven
mvn clean test -DtestNGXMLFile=src\test\resources\testng.xml
More information on apache maven-surefire-plugin for testng
Upvotes: 2