Java 单元测试中的回波不显示
我有一个ant项目,我在其中添加了AntUnitTest。这是执行测试的目标Java 单元测试中的回波不显示,java,ant,Java,Ant,我有一个ant项目,我在其中添加了AntUnitTest。这是执行测试的目标 <target name="test-build" depends="init-build"> <au:antunit> <fileset file="test.xml"/> <au:plainlistener/> <au:xmllistener todir="${reports.antunit.dir}"/&
<target name="test-build" depends="init-build">
<au:antunit>
<fileset file="test.xml"/>
<au:plainlistener/>
<au:xmllistener todir="${reports.antunit.dir}"/>
</au:antunit>
</target>
我见过echo在其他项目中使用,例如。如何让echo在单元测试中工作?捕获
echo
任务的输出,以便对其使用断言(即assertLogContains
)。在props中,当您在antunit之外手动运行目标时,它看起来好像有回声
如果要查看echo
的输出,需要将logforwarder
testlistener添加到antunit
任务中,即
<au:antunit>
<fileset file="test.xml"/>
<au:plainlistener/>
<au:xmllistener todir="${reports.antunit.dir}"/>
<au:logforwarder/>
</au:antunit>
您的
echo
任务的输出被捕获,以便您可以对其使用断言(即assertLogContains
)。在props中,当您在antunit之外手动运行目标时,它看起来好像有回声
如果要查看echo
的输出,需要将logforwarder
testlistener添加到antunit
任务中,即
<au:antunit>
<fileset file="test.xml"/>
<au:plainlistener/>
<au:xmllistener todir="${reports.antunit.dir}"/>
<au:logforwarder/>
</au:antunit>
我还没有尝试过这个,但我相信它会起作用。我还发现了显示所有断言宏的antlib.xml。这对试图学习antunit的人很有帮助。也感谢您参与antunit的开发!不客气。如果您从Apache(或其镜像之一)下载AntUnit发行版,它还包含一本手册。出于某种原因,我们仍然希望这是默认的分发点,所以不要费心把手册放到网上。哦,那太好了。我用常春藤来安装这个装置。这就是这个项目。github.com/moaxcp/gradle-to-antas该手册基本上包含静态HTML,您可以在中找到它,谢谢。这是一个很大的帮助。这将是很好的,有在生长激素的网页上发表。我还没有能够尝试这个,但我相信它会工作。我还发现了显示所有断言宏的antlib.xml。这对试图学习antunit的人很有帮助。也感谢您参与antunit的开发!不客气。如果您从Apache(或其镜像之一)下载AntUnit发行版,它还包含一本手册。出于某种原因,我们仍然希望这是默认的分发点,所以不要费心把手册放到网上。哦,那太好了。我用常春藤来安装这个装置。这就是这个项目。github.com/moaxcp/gradle-to-antas该手册基本上包含静态HTML,您可以在中找到它,谢谢。这是一个很大的帮助。这将是很好的,有发表在gh页。
<au:antunit>
<fileset file="test.xml"/>
<au:plainlistener/>
<au:xmllistener todir="${reports.antunit.dir}"/>
<au:logforwarder/>
</au:antunit>