|
另外jmeter提供了命令方式启动 运行测试用例 .脚本可以用ant写 .网上已经有人写了jmeter (ant的插件).在这个基础上 ,再写下ant的脚本就好了.
1.下载 ant-jmeter.jar 并且将ant-jmeter.jar 放ant 的库中(D:\apache-ant-1.7.0\lib)
http://www.programmerplanet.org/media/ant-jmeter/ant-jmeter.jar
2.
注
1)testplan_path 测试计划(.jmx)存放路径;
2)resultlog_path 测试结果存放路径;
3)test_fail_flag 测试失败的标志
4)循环执行testplan_path 路径下所有的测试计划,并将结果.jlt 存放resultlog_path 下;
// build.xml
<project name="antjmeter" default="run" basedir="." >
<property name="testplan_path" value="./testplan" />
<property name="resultlog_path" value="./resultlog" />
<property name="test_fail_flag" value="flase" />
<property name="true" value="true" />
<property name="jmeter_home" value="D:\jmeter_dist\" />
<target name="test">
<taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" />
<jmeter jmeterhome="${jmeter_home}" resultlogdir="${resultlog_path}" failureProperty="test_fail_flag" >
<testplans dir="${testplan_path}" />
<jvmarg value="-Dgroup1.threads=10"/>
</jmeter>
<echo message="jmeter test finished"/>
<echo message="test_fail_flag=${test_fail_flag}"/>
<condition property="test_fail_flag_ture">
<equals arg1="${test_fail_flag}" arg2="true" />
</condition>
<antcall target="ShowBuildFail" />
</target>
<target name="ShowBuildFail" if="test_fail_flag_ture">
<fail message="test result fail" />
</target>
<target name="interval">
<echo message="sleep 1 seconds"/>
<sleep seconds="1"/>
<echo message="continue"/>
</target>
<target name="run" depends="test,interval"/>
</project> |
|