I want to run test.xml
file through maven and command line. My test.xml
has 4 classes but unfortunately 'mvn test' command only picks one class.
Below is my project structure.
And here is the code for pom.xml
<groupId>com.mobikon.commontestapp</groupId>
<artifactId>commontestapp</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-configuration2</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
</property>
</properties>
<suiteXmlFiles>
<suiteXmlFile>test.xml</suiteXmlFile>
</suiteXmlFiles>
<!--<workingDirectory>target/</workingDirectory>-->
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
And Here is code for test.xml
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Mobikon Automation Tests" verbose="1" >
<test name="mEngage" >
<classes>
<class name="mengage.tests.LoginScenarios"></class>
<class name="mengage.tests.PurchaseCreditsTest"></class>
<class name="mengage.tests.VerifyTotalCustomers"></class>
<class name="mengage.tests.VerifyCredits"></class>
</classes>
</test>
</suite>
So now if I run maven from the command line this is the output.It is taking only PurchaseCredits class.
Command - mvn clean test
If I run from IntelliJ directly it is running properly, so the only issue I am facing is I am not able to run a proper test.xml
file from maven
after mvn -Ptest clean test, this is the screenshot for Maven enter image description here