Prerequisite: The original project all run normally, unit test normal execution.
The project began using MAVEN management and found that the original JUnit test could not be performed and the class could not be found (java.lang.ClassNotFoundException). In any case modifying the MAVEN configuration, the error is still.
Analysis Reason:
MyEclipse is able to identify items based on the . Project file, and the project's directory structure is defined in the . Classpath file. MyEclipse's JUnit plug-in is also based on the above file to find the source code and class file storage directory. After the project integrates MAVEN, the class file generation directory is specified by the Pom.xml file by executing the MAVEN command.
The project directory structure that MAVEN uses by default differs from the default directory structures in MyEclipse, when the directory specified in pom.xml file and the directory specified by the . Classpath file are not the same, and the error mentioned above is reported.
Therefore, when the project integrates MAVEN, the following are the areas to be noted when performing junit tests:
The following configuration in the Pom.xml file
should correspond to the following configuration in the. classpath file.
After this configuration, JUnit can execute correctly without affecting the functionality of MAVEN's packaging, publishing, and so on.
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/tools/