不显示 antunit 测试中的回声
Echo in antunit test is not displayed
我有一个 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
我在 props 等其他项目中看到过回声。如何让 echo 在 antunit 测试中工作?
您的 echo
任务的输出已被捕获,因此您可以对其使用断言(即 assertLogContains
)。在道具中,当您 运行 在 antunit 之外手动设置目标时,似乎 echo
就在那里。
如果您想查看 echo
的输出,您需要将 logforwarder
测试监听器添加到您的 antunit
任务中,即
<au:antunit>
<fileset file="test.xml"/>
<au:plainlistener/>
<au:xmllistener todir="${reports.antunit.dir}"/>
<au:logforwarder/>
</au:antunit>
我有一个 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
我在 props 等其他项目中看到过回声。如何让 echo 在 antunit 测试中工作?
您的 echo
任务的输出已被捕获,因此您可以对其使用断言(即 assertLogContains
)。在道具中,当您 运行 在 antunit 之外手动设置目标时,似乎 echo
就在那里。
如果您想查看 echo
的输出,您需要将 logforwarder
测试监听器添加到您的 antunit
任务中,即
<au:antunit>
<fileset file="test.xml"/>
<au:plainlistener/>
<au:xmllistener todir="${reports.antunit.dir}"/>
<au:logforwarder/>
</au:antunit>