Running testng suites in maven project

In pom.xml remove the junit dependency and add testng dependency instead. In this example we are using version 6.9.9 of testng .

<dependency> 
<groupId>org.testng</groupId> 
<artifactId>testng</artifactId> 
<version>6.9.9</version> 
<scope>test</scope> 
</dependency> 

Then if want to run our tests in a batch from a xml file we add the location of that xml file to our pom.xml as well.Please note we have also added the surefire plugin as well to generate maven surefire reports

<build> 
<plugins> 
<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-surefire-plugin</artifactId> 
<version>2.19.1</version> 
<configuration> 
<suiteXmlFiles> 
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> 
</suiteXmlFiles> 
</configuration> 
</plugin> 
</plugins> 
</build>