我对JUnit不是很熟悉,但我正在尝试将使用junit的ant目标转换为等级制。它没那么热,因为我在压舱一侧遇到了一些故障--我的印象是,这是由于输入没有被找到,但我无法证实,因为蚂蚁目标中不容易出现。
这是蚂蚁的脚本:
<target name="testing">
<junit printsummary="yes" showoutput="yes">
<classpath refid="classpath"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="someOutputLocation">
<fileset dir="${base}/testCode">
<include name="**/included.java"/>
<exclude name="**/excluded.java"/>
</fileset>
</batchtest>
</junit>
</target>下面是我的评分尝试的一个变体:
task testing(type:Test){
useJUnit()
testClassesDir = file("testCodeCompiled")
include '**/included.class'
exclude '**/excluded.class'
classpath = classpath
}我所犯的两个错误:
junit.framework.AssertionFailedError
java.lang.NullPointerException据推测,AssertionFailedError是由多个JUnit依赖关系引起的,而我没有这种依赖性。我只导入一个本地版本的junit-4.11。
我真的不知道为什么它不起作用,虽然我怀疑这是因为gradle的一些复杂性。我看到人们提到了一个ant-junit库,我可能会尝试使用它来至少复制gradle内部的结果。
编辑:出现了一个想法:我在gradle的一些src文件中找到了JUnit。通过调用useJUnit(),我可能会使用它吗?如果是这样的话,最终可能会出现双依赖关系吗?,不。分别去掉了useJUnit()和本地jar。前者表现得和以前一样,而后者则爆炸了。
更多信息:原因可能是compiledTestCode缺少了testCode包含的几个目录/数据。我可能得把相关文件复印一下。或者,是否有办法让gradle的JUnit使用.java文件而不是.class?
发布于 2016-09-02 13:08:53
对于那些想知道的人来说,代码是好的。我只是个哑巴。
https://stackoverflow.com/questions/39257650
复制相似问题