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!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.