ant构建自动化测试例子

<?xml version="1.0" encoding="UTF-8"?>
<project name="Test" >

	<!-- The local.properties file is created and updated by the 'android' tool.
         It contains the path to the SDK. It should *NOT* be checked into
         Version Control Systems. -->
	<loadproperties srcFile="local.properties" />
	<!-- The ant.properties file can be created by you. It is only edited by the
         'android' tool to add properties to it.
         This is the place to change some Ant specific build properties.
         Here are some properties you may want to change/update:

         source.dir
             The name of the source directory. Default is 'src'.
         out.dir
             The name of the output directory. Default is 'bin'.

         For other overridable properties, look at the beginning of the rules
         files in the SDK, at tools/ant/build.xml

         Properties related to the SDK location or the project target should
         be updated using the 'android' tool with the 'update' action.

         This file is an integral part of the build system for your
         application and should be checked into Version Control Systems.

         -->
	<property file="ant.properties" />

	<loadproperties srcFile="project.properties" />

	<!-- quick check on sdk.dir -->
	<fail
            message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
            unless="sdk.dir"
    />

	<import file="${sdk.dir}/tools/ant/build.xml" />

	<target name="start" >
		<antcall target="forinstall" />
	</target>

	<target name="forinstall" depends="myuninstall,myinstall" />
	
	<target name="myinstall" depends="os.env">
		<exec executable="${ant.executable}"  dir="." failοnerrοr="true">
      <redirector outputproperty="test0.log" alwayslog="true" append="true"/> 
			<arg value="-Dadb.device.arg"/>
			<arg value="-s ${deviceseri}" />
			<arg value="debug" />   
			<arg value="install"/>
		</exec>
    <echo message="${test0.log}" />
	</target>
	
	<target name="myuninstall" depends="os.env">
		<exec executable="${ant.executable}"  dir="." failοnerrοr="true">
      <redirector outputproperty="test1.log" alwayslog="true" append="true"/> 
			<arg value="-Dadb.device.arg"/>
			<arg value="-s ${deviceseri}" />
			<arg value="uninstall" />
		</exec>
    <echo message="${test1.log}" />
	</target>	

	<target name="test.with.failure" depends="os.env,clean,myuninstall,myinstall" >  
    		<exec executable="${ant.executable}"  dir="." failοnerrοr="true">
          <redirector outputproperty="test2.log" alwayslog="true" append="true"/> 
    			<arg value="-Dadb.device.arg"/>
    			<arg value="-s ${deviceseri}" />
    			<arg value="test" />
    		</exec>
    		<echo message="${test2.log}" />
    		<condition property="test.failed">
    			<or>
    				<contains string="${test2.log}" substring="Failure in" />
    				<contains string="${test2.log}" substring="Exception" />
    			</or>
    		</condition> 
		    <fail if="test.failed" message="Some test cases failed. Please take a look!" />    
        <antcall target="startCIC" />
	</target>
  
  <target name="startCIC" unless="test.failed">
		  <echo message="antcall CIC......" />
	    <antcall target="CIC-TestPlat" />
	</target>
  
	
	<!-- 判断操作系统类型 -->
	<target name="os.env" depends="windows.env,unix.env" />
  
  <condition property ="is.windows">
    <os family = "windows"/>
  </condition >

	<target name="windows.env" if="is.windows">
		<property name="ant.executable" value="ant.bat" />
	</target>

	<target name="unix.env" unless="is.windows">
		<property name="ant.executable" value="ant" />
	</target>

	<!-- deploy -->
	<target name="deploy">
		<copy file="${apk.file}" todir="${deploy.dest}" />
	</target>

</project>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值