Luis Sigal | 8da3e6e | 2011-02-24 17:22:33 +0000 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <project name="Android Mock" default="all-tests" basedir="."> |
| 3 | <description> |
| 4 | Android Mock is a wrapper for EasyMock (2.4) which allows for real Class mocking on |
| 5 | an Android (Dalvik) VM. |
| 6 | |
| 7 | All methods on Android Mock are syntactically equivalent to EasyMock method |
| 8 | calls, and will delegate calls to EasyMock, while performing the required |
| 9 | transformations to avoid Dalvik VM troubles. |
| 10 | |
| 11 | Calls directly to EasyMock will work correctly only if the Class being mocked |
| 12 | is in fact an Interface. Calls to Android Mock will work correctly for both |
| 13 | Interfaces and concrete Classes. |
| 14 | |
| 15 | Android Mock requires that the code being mocked be instrumented prior to |
| 16 | loading to the Dalvik VM by having called the MockGenerator.jar file. Try |
| 17 | running java -jar MockGenerator.jar --help for more information. |
| 18 | </description> |
| 19 | |
| 20 | <!-- Global Build Properties --> |
| 21 | <property file="build.properties"/> |
| 22 | |
| 23 | <!-- Imports --> |
| 24 | <import file="src/build-runtime.xml"/> |
| 25 | <import file="src/build-mockgen.xml"/> |
| 26 | <import file="src/build-framework-gen.xml"/> |
| 27 | |
| 28 | <!-- Android Mock Source Jar Properties --> |
| 29 | <property name="source-bin" value="bin/source"/> |
| 30 | <property name="source-lib-jar" value="AndroidMock-src.jar"/> |
| 31 | |
| 32 | <!-- Android Mock Test Properties --> |
| 33 | <property name="junit-jar" value="junit.jar"/> |
| 34 | <property name="test-bin" value="bin/tests"/> |
| 35 | <property name="test-results-folder" value="${test-bin}/results"/> |
| 36 | <property name="test-source-base" value="tests"/> |
| 37 | |
| 38 | <!-- Classpaths --> |
| 39 | <path id="tests.path"> |
| 40 | <pathelement location="${lib-folder}/${easymock-jar}"/> |
| 41 | <pathelement location="${lib-folder}/${javassist-jar}"/> |
| 42 | <pathelement location="${runtime.bin}/${runtime.deploy-jar}"/> |
| 43 | <pathelement location="${mockgen.bin}/${mockgen.deploy-jar}"/> |
| 44 | <pathelement location="${lib-folder}/${junit-jar}"/> |
| 45 | </path> |
| 46 | |
| 47 | <!-- Private Build Targets --> |
| 48 | <target name="-dirs"> |
| 49 | <mkdir dir="${source-bin}"/> |
| 50 | <mkdir dir="${test-bin}"/> |
| 51 | <mkdir dir="${staging}"/> |
| 52 | <mkdir dir="${test-results-folder}"/> |
| 53 | </target> |
| 54 | |
| 55 | <target name="-clean-staging"> |
| 56 | <delete dir="${staging}"/> |
| 57 | </target> |
| 58 | |
| 59 | <!-- Public Build Targets --> |
| 60 | <target name="clean" depends="-clean-staging,mockgen.clean,runtime.clean"> |
| 61 | <delete dir="${source-bin}"/> |
| 62 | <delete dir="${framework-mock-staging}"/> |
| 63 | <delete dir="${test-results-folder}" failonerror="false"/> |
| 64 | <delete dir="${test-bin}" failonerror="false"/> |
| 65 | </target> |
| 66 | |
| 67 | <target name="build-dist" |
| 68 | depends="mockgen.build-deploy, runtime.build-deploy, build-source-lib"/> |
| 69 | |
| 70 | <target name="build-source-lib" depends="-dirs" |
| 71 | description="Builds a jar file containing the Android Mock source files (no dependencies)"> |
| 72 | <jar destfile="${source-bin}/${source-lib-jar}" basedir="${source-base}" includes="**/*.java"/> |
| 73 | </target> |
| 74 | |
| 75 | <!-- Public Test Targets --> |
| 76 | <target name="all-tests" depends="-test-base" |
| 77 | description="Builds the full distribution package and runs all tests storing results in ${test-results-folder}"> |
| 78 | <junit printsummary="no" showoutput="no" reloading="false" failureproperty="testsFailed"> |
| 79 | <formatter type="xml"/> |
| 80 | <classpath location="${test-bin}"/> |
| 81 | <classpath refid="tests.path"/> |
| 82 | <batchtest todir="${test-results-folder}"> |
| 83 | <fileset dir="${test-bin}"> |
| 84 | <include name="**/*Test.class"/> |
| 85 | <include name="**/*Tests.class"/> |
| 86 | </fileset> |
| 87 | </batchtest> |
| 88 | </junit> |
| 89 | <echo>Test Results are available in ${test-results-folder}</echo> |
| 90 | <junitreport todir="${test-results-folder}"> |
| 91 | <fileset dir="${test-results-folder}"> |
| 92 | <include name="TEST-*.xml"/> |
| 93 | </fileset> |
| 94 | <report format="frames" todir="${test-results-folder}/html"/> |
| 95 | </junitreport> |
| 96 | <fail if="testsFailed" message="Tests failed"/> |
| 97 | </target> |
| 98 | |
| 99 | <!-- Private Test Targets --> |
| 100 | <target name="-test-base" depends="build-dist"> |
| 101 | <javac destdir="${test-bin}" target="1.5" srcdir="${test-source-base}" |
| 102 | debug="true" > |
| 103 | <compilerarg value="-proc:none"/> |
| 104 | <classpath refid="tests.path"/> |
| 105 | </javac> |
| 106 | </target> |
| 107 | |
| 108 | </project> |