更新时间:2023-11-15 17:59:04
您粘贴的代码相当于调用 junitreport 任务:
The code you've pasted is the equivalent of calling the junitreport task:
<junitreport todir="..">
<fileset dir="..">
<include name="TEST-*.xml" />
</Fileset>
<report format="frames" todir=".." />
</Junitreport>
你需要把它放到一个方法中并自己运行.此代码将获取所有名为 TEST-*.xml
的文件并使用它们创建报告.它不会创建这些文件.这些文件是由 Ant 中的 junit 任务创建的.所以你需要:
You need to put this into a method and run it yourself. This code will take all files called TEST-*.xml
and create a report with them. It will not create those files. Those files are created by the junit task in Ant. So you need to:
最简单的方法可能就是您所做的,在某处放置一个 build.xml
,然后直接调用 ant.如果您使用的文件集是稳定的,那么这可能是最简单的方法.为此,请使用 ProcessBuilder java 类.
The easiest way to do this is probably what you've done, to have a build.xml
somewhere, and invoke ant directly. If the fileset you're using is stable, then this is probably the easiest way to go. Use the ProcessBuilder java class for this.