junit4报测试类class not found

项目中编写测试类,运行Run As —> Junit Test,会报错class not found。

class not found肯定是没有编译成功。project—>clean—>重新编译,还是报错。其实要运行Junit必须在target/test-classes找到编译类。

解决方法:
在pom.xml文件中,Run As —> maven test,会发现target/test-classes编译的类。console中可以看到运行maven test的相关信息或错误,在surefire-reports文件夹也可以找到编译的信息。这样再运行就可以了。
在这里插入图片描述