When the Spring Framework project is tested with JUnit, the program automatically compiles with the following issues:
The problem with the program is that there are no Org.junit.runners.BlockJUnit4ClassRunner found in the project, there are two possibilities, one is that the jar is not imported into JUnit, and the other is that there is no such class in the version of the imported JUnit jar.
1, first confirm whether to import the jar package
2, since the jar has been imported, then on the JUnit website to see the version of JUnit now
Summarize:
1, fully can certainly be the version issue, JUnit for a higher version, problem solving.
2, after investigation to understand that Spring3 provides Springjunit4classrunner base class so that we can easily access JUNIT4, and Org.springframework.test.context.junit4.SpringJUnit4ClassRunner Inherit the Org.junit.runners.BlockJUnit4ClassRunner, where the Blockjunit4classrunner class is included in the version above junit4.5.
3, when using junit4.11 version, the official website is required junit-4.11.jar + Hamcrest-core-1.3.jar, if not added hamcrest-core-1.3.jar java.lang.noclassdeffounderror:org/hamcrest/ Selfdescribing error. If the 4.11 version requires two jars Plus, or a lower version, &NBSP is provided in the shared file below, and the junit4.7 version.
Warm tips: The junit-4.11 jar package is shared, and the shared file includes JUnit's jar package, source code, documentation.
Baidu Network disk: Link: http://pan.baidu.com/s/1mgvFIje Password: 8SSF
2017-12-27 Update
Oneself also encountered this problem, according to the above solution not, their own MAVEN import is junit4.12 later himself after debugging found, is the version problem, changed to 4.11 No problem, the code is as follows
@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration"classpath:spring/spring-dao.xml""classpath:spring/spring-service.xml" })publicclass BaseTest {}
Spring project with JUnit appears Org.junit.runners.BlockJUnit4ClassRunner cannot be resolved (RPM)