谢谢大家的时间和回答。我现在找到了解决方案。以前,我认为我的ant目标的batchtest部分的输入应该是.class文件,但也可以使用.java文件。
那解决了问题。现在,它不再抱怨内部类缺少公共构造函数。
<target name="junit" description="Execute unit tests"> <delete dir="tmp/rawtestoutput"/> <delete dir="test-reports"/> <mkdir dir="tmp/rawtestoutput"/> <junit printsummary="on" failureproperty="junit.failure" fork="true"> <jvmarg value="-Duser=TBA -Dpassword=ibber11"/> <classpath refid="class.path.test"/> <classpath refid="class.path.model"/> <classpath refid="class.path.gui"/> <classpath refid="class.path.jfreereport"/> <classpath path="tmp/${test.jar}"/> <batchtest todir="tmp/rawtestoutput"> <fileset dir="src/test"> <include name="**SessionHelper.java"/> <exclude name="**/TestHelper.java"/> </fileset> </batchtest> <sysproperty key="user" value="tba"/> <sysproperty key="password" value="ibber11"/> </junit> <junitreport todir="tmp"> <fileset dir="tmp/rawtestoutput"/> <report todir="test-reports"/> </junitreport> <fail if="junit.failure" message="Unit test(s) failed. See reports!"/></target>我现在唯一的问题是,必须过滤掉没有测试的测试类,以免出现“无可运行方法”错误。也就是说,helper和util类。
助手类不包含@Test注释。必须有可能以某种方式利用这一点…



