This page is hosted for free by, if you are owner of this page, you can remove this message and gain access to many additional features by upgrading your hosting to PRO or VIP for just 41.60 UAH.
Do you want to support owner of this site? Click here and donate to his account some amount, he will be able to use it to pay for any of our services, including removing this ad.

Cannot find class in classpath, what to do in this case

If you runing your test using  command from project home derectory

mvn clean test

And you receive error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project “your project name”: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process
[ERROR] org.testng.TestNGException:
[ERROR] Cannot find class in classpath: “Class with your tests”

There are few ways to resolve problem:

  1. Rebuild project using Builds->

2. Run command from project home derectory

mvn surefire:test

if you use org.apache.maven.plugins:maven-surefire-plugin:2.19.1 to run tests better to use mvn mvn surefire:test

Also be sure that you configure plugin in a proper way and set correct location for testng.xml

            <suiteXmlFile>src/resources/testng.xml</suiteXmlFile><!--your testng.xml location-->

Mostly this issue connected with incorrect configuration of pom xml