我想解决如何在没有实际需要build.xml的情况下运行ant任务。 特别是我想用格式化程序运行JUnit
任务。以XML格式,这看起来象下面这样:在没有build.xml的情况下运行junit ant任务
<junit printsummary="true" errorProperty="test.failed" failureProperty="test.failed">
<classpath refid="run.class.path" />
<!-- console log -->
<formatter type="xml" classname="be.x.SFFormatter" />
<test name="be.x.SF" outfile="result" todir="${build.output.dir}" />
</junit>
运行Ant脚本时,它的工作原理,但我希望得到我的应用程序运行作为一个可运行的罐子。 运行从Java测试很简单:
JUnitCore junit = new JUnitCore();
testResult = junit.run(SeleniumFramework.class);
不过,我努力工作,如何真正得到格式化工作。 格式化程序的类型是org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter
,所以我怀疑我可以在没有运行ant的地方插入它。
有没有人做过类似的事情? 谢谢!
我决定将构建文件捆绑到我的jar中并在内部运行它。有点难过,它使我的最终产品依赖于蚂蚁,但现在我可以忍受它 – 2012-07-24 08:48:56