Solution: In your pom.xml file remove the scope and this should work fine. Because, even though we have imported the maven dependency for Testng, when you add scope tag in XML file, it treats as JUnit annotation and not as Testng. So when you removed scope tag, @Test Annotation treated as Testng Annotation.
<dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.8.7</version> **<scope>test</scope>** //Remove this line and compile maven </dependency>
Fix in Eclipse:
1. Open pom.xml file.
2. Go to “Dependencies” tab.
3. Select “testng” package and click on “Properties…”
4. On opened screen change “Scope” option to “compile” and click “OK” to save it.
5. Try to build your project again with “compile test” goals.