I\'m pretty new to maven and I want to run my test classes using maven. I have generated the testng.xml and I have created the POM.xml file also. But when you run the
Make sure your tests are in "src/test/java". It will solve this problem
remove test scope testng dependency and add compile
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
<scope>compile</scope>
</dependency>
Below solution works for me-
Please add below dependencies in your pom.xml
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>17.0</version>
</dependency>
I've got similar problem. The reason for that was "Scope" option of "testng" dependency set to "test" when "compile" was needed.
How I fixed it (note, I used Eclipse):
In your pom.xml file you have scope of testng as test
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.13.6</version>
<scope>test</scope>
</dependency>
Replace the scope by compile
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.13.6</version>
<scope>compile</scope>
</dependency>