<?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>
ant构建自动化测试例子
最新推荐文章于 2020-06-07 21:03:19 发布