1 <?xml version="1.0" encoding="UTF-8"?> 2 3 <!-- 4 Copyright (c) 2009, 2015 Mountainminds GmbH & Co. KG and Contributors 5 All rights reserved. This program and the accompanying materials 6 are made available under the terms of the Eclipse Public License v1.0 7 which accompanies this distribution, and is available at 8 http://www.eclipse.org/legal/epl-v10.html 9 10 Contributors: 11 Brock Janiczak - initial API and implementation 12 13 $Id: $ 14 --> 15 16 <project name="JaCoCo Merge Task Tests" xmlns:au="antlib:org.apache.ant.antunit" xmlns:jacoco="antlib:org.jacoco.ant"> 17 18 <target name="setUp"> 19 <tempfile property="temp.dir" prefix="jacocoTest" destdir="${java.io.tmpdir}" /> 20 <mkdir dir="${temp.dir}"/> 21 <property name="exec.file" location="${temp.dir}/exec.file" /> 22 </target> 23 24 <target name="tearDown"> 25 <delete dir="${temp.dir}" quiet="false" failonerror="true"/> 26 </target> 27 28 <target name="testMergeNoDestination"> 29 <au:expectfailure expectedMessage="Destination file must be supplied"> 30 <jacoco:merge/> 31 </au:expectfailure> 32 </target> 33 34 <target name="testMergeToDirectory"> 35 <au:expectfailure expectedMessage="Unable to write merged file ${temp.dir}"> 36 <jacoco:merge destfile="${temp.dir}"/> 37 </au:expectfailure> 38 </target> 39 40 <target name="testMergeEmptySet"> 41 <jacoco:merge destfile="${exec.file}"/> 42 43 <au:assertFileExists file="${exec.file}"/> 44 </target> 45 46 <target name="testMergeMultipleFiles"> 47 <jacoco:merge destfile="${exec.file}"> 48 <fileset dir="${basedir}/data" includes="*.exec"/> 49 </jacoco:merge> 50 51 <property name="sample1.file" location="${basedir}/data/sample1.exec"/> 52 <property name="sample2.file" location="${basedir}/data/sample2.exec"/> 53 <au:assertLogContains text="Loading execution data file ${sample1.file}"/> 54 <au:assertLogContains text="Loading execution data file ${sample2.file}"/> 55 <au:assertLogContains text="Writing merged execution data to ${exec.file}"/> 56 <au:assertFileExists file="${exec.file}"/> 57 </target> 58 59 <target name="testMergeBadFiles"> 60 <property name="bad.file" location="${basedir}/data/sample.bad"/> 61 <au:expectfailure expectedMessage="Unable to read ${bad.file}"> 62 <jacoco:merge destfile="${exec.file}"> 63 <file file="${basedir}/data/sample.bad"/> 64 </jacoco:merge> 65 </au:expectfailure> 66 </target> 67 68 <target name="testMergeDirectory"> 69 <jacoco:merge destfile="${exec.file}"> 70 <dirset dir="${basedir}/data"/> 71 </jacoco:merge> 72 73 <au:assertFileExists file="${exec.file}"/> 74 </target> 75 </project>