TestNG - No tests found, how can this be resolved?

364    Asked by AndreaBailey in QA Testing , Asked on Apr 26, 2022

 UTF-8 io.rest-assured rest-assured 4.1.2 test org.testng testng 6.14.3 ************************************************** TestNg.xml

Answered by Anisha Dalal

Your pom.xml has to include maven surefire plugin inside

...

tags: ...




org.apache.maven.plugins
maven-surefire-plugin
2.19.1


src/test/testng.xml






...


Then you can execute your tests by running mvn tests.
Bear in mind it will pick up every class that has a ...test suffix and look for methods annotated with @Test only in such classes.

How to execute a single test (question in comments):
You can provide method name in testng.xml file, like this:














Or simply run it via maven:

mvn test -Dtest=className#methodName
When executing a single test via maven, you might need to add -DfailIfNoTests=false so that maven does not fail and you won't receive the message of - no tests found, when multiple modules exist.


Your Answer

Interviews

Parent Categories