使用junit测试,找不到org.junit,hamcrestSelfDescribing错误

    技术2022-07-12  61

    总结一下自己的心路历程。 1.按照https://www.cnblogs.com/qinxu/p/7844964.html 步骤按照了junit相关插件 如果像我这样没有browse repository在下面,直接在搜索框里搜一下,然后再搜索junit,就能找到了

    2.报错。说找不到org.junit https://blog.csdn.net/he99774/article/details/78254262

    2.报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误 搜索后发现是这个问题 https://blog.csdn.net/u011954243/article/details/77962329 选择了junit4.12 + hamcrest-core-1.3.jar https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core/1.3 选择Files那行的jar(43KB)下载。

    3.仍然报错,这时候发现jar包内并没有junit4.12 然后,把junit4.12和hamcrest-core-1.3.jar手动复制导入

    4.仍然报错, https://blog.csdn.net/cao_scdn/article/details/79998127?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-1

    若使用intellij idea则在.iml配置文件中添加

    5.如果你像我一样,在多个文件夹内都有测试用例 那么一定还有重复2的步骤,给每个文件都添加jar包应用。 (我添加过到Global Libraries,但是还得重复步骤2,才能用,具体的情况我也不是很了解了,欢迎大家给出解决策略) 在这里面选择你要添加junit到哪个文件夹

    Processed: 0.010, SQL: 9