我们使用ant来运行所有的JUnitTests。我们的批量测试看起来像:
<batchtest todir="${test.reports}">
<!-- First fork -->
<fileset dir="${build.out.dir}/plugins/plugin1/test" includes="**/*Test.java" />
<fileset dir="${build.out.dir}/plugins/plugin2/test" includes="**/*Test.java" />
<fileset dir="${build.out.dir}/plugins/plugin3/test" includes="**/*Test.java" />
<fileset dir="${build.out.dir}/plugins/plugin4/test" includes="**/*Test.java" />
<fileset dir="${build.out.dir}/plugins/plugin5/test" includes="**/*Test.java" />
<fileset dir="${build.out.dir}/plugins/plugin6/test" includes="**/*Test.java" />
<fileset dir="${build.out.dir}/plugins/util/test" includes="**/*Test.java" />
</batchtest>
问题在于,如果有人正在添加新插件而忘记在此处添加文件集,则测试不会运行。所以我试着写下这样的东西:
<batchtest todir="${test.reports}">
<!-- First fork -->
<fileset dir="${build.out.dir}/plugins" includes="**/test/**/*Test.java" />
</batchtest>
但运行此测试时所有测试都失败了。而我正在
java.lang.ClassNotFoundException: build.test.com.something.something.something.something.something.something.somethngTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
任何想法?