首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

经过Ant运行单个测试用例并添加JVM参数<转>

2012-11-07 
通过Ant运行单个测试用例并添加JVM参数转fail messageYou must run this target with -DtestTestNam

通过Ant运行单个测试用例并添加JVM参数<转>

<fail message="You must run this target with -Dtest=TestName"/>

</target>

<target name="ensure-jvmarg" unless="jvm.arg">

<fail message="You must run this target with -Djvm.arg=args"/>

</target>

<target name="runtest" depends="compile, ensure-test-name,ensure-jvmarg">

<junit printsummary="withOutAndErr" fork="yes" timeout="6000">?

<classpath refid="junit.classpath" />

<formatter type="plain" usefile="false"/>

<batchtest>

<fileset dir="src/test">

<include name="**/${test}.java"/>

</fileset>

</batchtest>

<jvmarg value="${jvm.arg}"/>

</junit>

</target>

?

?

?

运行命令为:

ant runtest -f your_build.xml?-Dtest=XXXTest -Djvm.arg="-agentlib:xxxagent -Xmx128m"

-f指定build.xml的目录,-Dtest为所要运行的Testcase文件,程序为在src/test(位于junit->batchtest->fileset标签下,可自定义)这个目录下寻找以包含XXXTest的java文件(可用通配符作为输入)。-Djvm.arg即为输入的jvm参数。

update:

timeout参数可指定一个时间(以毫秒计数),超过此时间自动kill该进程。

?

?

?

热点排行