gpt4 book ai didi

java - Antunit测试中回声不显示

转载 作者:行者123 更新时间:2023-12-02 02:25:30 25 4
gpt4 key购买 nike

我有一个 ant 项目,其中添加了 antunit 测试。这是执行测试的目标。

<target name="test-build" depends="init-build">
<au:antunit>
<fileset file="test.xml"/>
<au:plainlistener/>
<au:xmllistener todir="${reports.antunit.dir}"/>
</au:antunit>
</target>

test.xml 看起来像这样

<project xmlns:au="antlib:org.apache.ant.antunit">
<include file="build.xml" as="main"/>

<target name="tearDown" depends="main.clean"/>

<target name="test-project-name">
<echo>project name is ${ant.project.name}</echo>
<au:assertTrue>
<equals arg1="${ant.project.name}" arg2="gradle-to-ant"/>
</au:assertTrue>
</target>
</project>

当我运行 ant test-build 时,echo 语句不会打印到控制台或报告。

test-build:
[au:antunit] Build File: /etc/user/john/projects/gradle-to-ant/test.xml
[au:antunit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.033 sec
[au:antunit] Target: test-project-name took 0.012 sec

BUILD SUCCESSFUL
Total time: 0 seconds

我见过 echo 在其他项目中使用,例如 props 。如何让 echo 在 Antunit 测试中工作?

最佳答案

捕获 echo 任务的输出,以便您可以对其使用断言(即 assertLogContains)。在 props 中,当您在 antunit 之外手动运行目标时,看起来好像存在 echo

如果您想查看 echo 的输出,您需要将 logforwarder 测试监听器添加到您的 antunit 任务中,即

<au:antunit>
<fileset file="test.xml"/>
<au:plainlistener/>
<au:xmllistener todir="${reports.antunit.dir}"/>
<au:logforwarder/>
</au:antunit>

关于java - Antunit测试中回声不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47855620/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com