有两个Module, ModuleA/ModuleB,如果ModuleB的test中引用到ModuleA/test中的类,那么Junit运行时就会报java.lang.NoClassDefFoundError。如果ModleB在test中引用的不是ModuleA/test中的类,而是ModuleA/main中的类就没有问题。
google了一下,似乎是Maven在解析dependency时不包括test scope的问题。也不清楚是不是hit了这个bug ,但那个bug的status应该是在05年就fix了啊。
现在没时间详细研究,解决方法就是先把那个出问题的类从/test移到/main中。不过那个类其实是个AbstractDBTest类,这样放到/main中真是看着浑身不爽。有空还是要研究个nice solution。