Reputation: 489
Using Java and Eclipse and TestNG, I've put together a simple Maven test automation framework project with a single test case class. But regardless of building and rebuilding and cleaning the project, every time I try running the test case from the test case class itself or from the testng.xml file, I get the dreaded "Cannot find class in classpath" error for my test class.
I've included two screenshots. The first has focus on my testng.xml file so you can see how my test class "SampleTest.java" is mapped. As you can see, it's mapped as <class name="src.test.java.myframework.SampleTest"/>
but I've also tried <class name="test.java.myframework.SampleTest"/>
and <class name="java.myframework.SampleTest"/>
and <class name="myframework.SampleTest"/>
but I get the same "Cannot find class" error no matter which path I use. I've even tried including .java to the end of the file name. I've also tried uninstalling TestNG and then reinstalling, building and cleaning the project multiple times, as well as quitting and restarting Eclipse to no avail.
In the second screenshot, I show my project's build path.
If someone could tell me what I'm doing wrong-- if anything, I would be most obliged!
Upvotes: 0
Views: 550
Reputation: 838
Try without src/test/java, this is working for me. please ref screenshot,
<classes>
<class name="myframework.SampleTest"/>
</classes>
if not please reinstall mvn and testng plugin
Upvotes: 0