Ant Junit 测试通过 ant 运行比通过 IDE 慢得多 - 看什么? [英] Ant Junit tests are running much slower via ant than via IDE - what to look at?

查看:23
本文介绍了Ant Junit 测试通过 ant 运行比通过 IDE 慢得多 - 看什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 ant 运行我的 junit 测试,它们的运行速度比通过 IDE 慢得多.我的蚂蚁电话是:

I am running my junit tests via ant and they are running substantially slower than via the IDE. My ant call is:

    <junit fork="yes" forkmode="once" printsummary="off">
        <classpath refid="test.classpath"/>
        <formatter type="brief" usefile="false"/>
        <batchtest todir="${test.results.dir}/xml">
            <formatter type="xml"/>
            <fileset dir="src" includes="**/*Test.java" />
        </batchtest>
    </junit>

在我的 IDE (0.067s) 中几乎立即运行的相同测试在通过 Ant 运行时需要 4.632s.过去,我已经能够通过使用 junit fork 参数来加快此类测试问题的速度,但这在这种情况下似乎无济于事.我可以查看哪些属性或参数来加速这些测试?

The same test that runs in near instantaneously in my IDE (0.067s) takes 4.632s when run through Ant. In the past, I've been able to speed up test problems like this by using the junit fork parameter but this doesn't seem to be helping in this case. What properties or parameters can I look at to speed up these tests?

更多信息:

我使用的是 IDE 报告的时间与 junit 任务输出的时间.这不是蚂蚁运行结束时报告的总时间.

I am using the reported time from the IDE vs. the time that the junit task outputs. This is not the sum total time reported at the end of the ant run.

所以,奇怪的是,这个问题已经自行解决了.是什么导致了这个问题?系统在本地磁盘上运行,所以这不是问题.

So, bizarrely, this problem has resolved itself. What could have caused this problem? The system runs on a local disk so that is not the problem.

推荐答案

我猜这是因为您的 antscript 将结果输出到 XML 文件,而 IDE 将这些结果保存在内存中.写文件比不写文件要花更长的时间.

I'm guessing it's because your antscript is outputing results to XML files, whereas the IDE is keeping those in memory. It takes longer to write a file than to not write a file.

todir="${test.results.dir}/xml"

这是 <batchtest> 调用的一部分,它告诉它将结果粘贴到该目录中.看起来离开它只是告诉它把结果粘贴在当前目录"中,无论是什么.乍一看,我没有看到任何可以完全关闭它的东西.

That's the part of the <batchtest> call that tells it to stick the results into that directory. It looks like leaving it off just tells it to stick the results in the "current directory", whatever that is. At first glance I didn't see anything to turn it all the way off.

这篇关于Ant Junit 测试通过 ant 运行比通过 IDE 慢得多 - 看什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆