blob: 91f7301deb326d80b8096ecbc4e481f81e6c2567 [file] [log] [blame]
<?xml version="1.0"?>
<!--
Copyright 1999-2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<project name="test">
<description>Test targets</description>
<!--+
| Runs all tests
+-->
<target name="test" depends="junit-tests, anteater-tests"
description="Runs all tests"/>
<!--+
| Runs JUnit tests
+-->
<target name="junit-tests" depends="core-junit-tests, block-junit-tests, junit-tests-report"
description="Runs JUnit tests"/>
<target name="junit-tests-prepare">
<delete dir="${build.test.output}"/>
<delete dir="${build.test.report}"/>
<mkdir dir="${build.test.output}"/>
</target>
<!-- Runs JUnit tests -->
<target name="core-junit-tests" depends="compile-tests, junit-tests-prepare">
<junit printsummary="yes" fork="yes" failureproperty="junit.test.failed">
<jvmarg value="-Djava.endorsed.dirs=lib/endorsed"/>
<jvmarg value="-Djunit.test.loglevel=${junit.test.loglevel}"/>
<jvmarg line="${junit.test.jvmargs}"/>
<classpath>
<path refid="test.classpath"/>
</classpath>
<formatter type="plain" usefile="no"/>
<formatter type="xml"/>
<batchtest todir="${build.test.output}">
<fileset dir="${build.test}">
<include name="${junit.test.include.1}"/>
<include name="${junit.test.include.2}"/>
<exclude name="**/AllTest.class" />
<exclude name="**/CocoonBeanTestCase.class" />
<exclude name="**/*$$*Test.class" />
<exclude name="**/Abstract*.class" />
<exclude name="**/SitemapComponentTestCase*"/>
<exclude name="**/SitemapTestCase*"/>
<exclude name="**/ContainerTestCase*"/>
<exclude name="**/CocoonTestCase*"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- Runs one JUnit test -->
<target name="core-junit-test" depends="compile-tests, junit-tests-prepare">
<fail unless="junit.testcase"
message="Please set the property $${junit.testcase} to a JUnit testcase (package.Classname, e.g. org.test.MyTestCase)."/>
<junit printsummary="yes" fork="yes" failureproperty="junit.test.failed">
<jvmarg value="-Djava.endorsed.dirs=lib/endorsed"/>
<jvmarg value="-Djunit.test.loglevel=${junit.test.loglevel}"/>
<classpath>
<path refid="test.classpath"/>
</classpath>
<formatter type="plain" usefile="no"/>
<formatter type="xml"/>
<test name="${junit.testcase}" todir="${build.test.output}"/>
</junit>
</target>
<!-- Runs JUnit tests in debug mode -->
<target name="junit-test-debug" depends="compile-tests, junit-tests-prepare">
<fail unless="junit.testcase"
message="Please set the property $${junit.testcase} to a JUnit testcase (package.Classname, e.g. org.test.MyTestCase)."/>
<echo message="The JVM will be suspended until you connect with your favourite debugger to port ${junit.test.debugport}."/>
<junit printsummary="yes" fork="yes" failureproperty="junit.test.failed">
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${junit.test.debugport}"/>
<jvmarg value="-Djunit.test.loglevel=${junit.test.loglevel}"/>
<classpath refid="test.classpath"/>
<formatter type="plain"/>
<formatter type="xml"/>
<test name="${junit.testcase}" todir="${build.test.output}"/>
</junit>
</target>
<!-- Block tests -->
<target name="block-junit-tests" depends="compile-tests, prepare-blocks">
<ant antfile="${build.temp}/blocks-build.xml"
inheritAll="true"
inheritRefs="false"
target="tests"/>
</target>
<target name="junit-tests-report">
<mkdir dir="${build.test.report}"/>
<junitreport todir="${build.test.output}">
<fileset dir="${build.test.output}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${build.test.report}"/>
</junitreport>
<echo message="Unit report is at ${build.test.report}/index.html"/>
<fail if="junit.test.failed"
message="One or more JUnit tests failed or caused errors. Please have a look into the report for details."/>
</target>
<!--+
| Anteater tests
+-->
<!-- Anteater tests -->
<target name="anteater-tests" depends="block-anteater-tests, core-anteater-tests"
description="Runs AntEater tests"/>
<!-- Ant macro that calls anteater -->
<macrodef name="call-anteater">
<attribute name="script"/>
<attribute name="target"/>
<attribute name="targetfile"/>
<sequential>
<java classname="org.apache.tools.ant.Main" fork="true" failonerror="true">
<classpath>
<fileset dir="${anteater.home}">
<include name="lib/**/*.jar"/>
<include name="tomcat/**/*.jar"/>
</fileset>
<pathelement location="${anteater.home}/resources"/>
</classpath>
<jvmarg value="-Dant.home=${anteater.home}"/>
<jvmarg value="-Danteater.home=${anteater.home}"/>
<jvmarg value="-Danteater.resources=${anteater.home}/resources"/>
<jvmarg value="-Danteater.report=${anteater.home}/resources/scripts/report.xml"/>
<jvmarg value="-Djava.endorsed.dirs=${anteater.home}/lib"/>
<arg line="-f ${build.test}/anteater/@{script} -Dhost=${anteater.target.host} -Dport=${anteater.target.port} -Dbase=${anteater.target.base.path} -Ddefault.haltonerror=${anteater.option.haltonerror} -Dtargetfile=@{targetfile} @{target}"/>
</java>
</sequential>
</macrodef>
<target name="anteater-tests-prepare">
<!-- check whether Anteater is installed and available -->
<!-- anteater parameters are set in build.properties -->
<available file="${anteater.home}" property="anteater.present"/>
<fail unless="anteater.present"
message="To use anteater, please install it and set anteater.home (currently ${anteater.home}) in your local.build.properties"/>
<echo>*** Anteater notes ***</echo>
<echo>a) To run these tests, another instance of Cocoon must be</echo>
<echo> running at ${anteater.target.host}:${anteater.target.port} (base path=${anteater.target.base.path})</echo>
<echo>b) JDK 1.4.x is required to run these tests, but running them</echo>
<echo> under 1.4.x to test Cocoon running under 1.3.x should be ok.</echo>
<echo>c) anteater options can be set in local.build.properties, and some</echo>
<echo> tests only run if enabled there.</echo>
</target>
<!-- Anteater tests -->
<target name="core-anteater-tests" depends="compile-tests, anteater-tests-prepare"
description="Runs anteater tests">
<call-anteater script="run-tests.xml" target="all" targetfile=""/>
</target>
<!-- Run a SINGLE Anteater tests -->
<target name="anteater-test" depends="compile-tests, anteater-tests-prepare, block-anteater-tests"
description="Runs a single Anteater test">
<echo>d) to run the tests in 'calc.xml' call 'build anteater-test -Dtarget=calc'</echo>
<call-anteater script="run-tests.xml" target="single" targetfile="${target}"/>
</target>
<!-- Block tests -->
<target name="block-anteater-tests" depends="prepare-blocks">
<ant antfile="${build.temp}/blocks-build.xml"
inheritAll="true"
inheritRefs="false"
target="prepare-anteater-tests"/>
</target>
<!--+
| Clover tasks
+-->
<target name="clover">
<available property="clover.present"
classname="com.cortexeb.tools.clover.tasks.CloverTask">
<classpath refid="classpath"/>
</available>
<!-- echo message="Clover present: ${clover.present}"/ -->
</target>
<target name="clover.init" depends="clover" if="clover.present">
<taskdef resource="clovertasks"/>
</target>
<target name="clover.on" depends="clover.init" if="clover.present">
<!-- echo message="Clover is ON!"/ -->
<echo message="Clover is present? ${clover.present}"/>
<clover-setup initString="${build}/clover/coverage.db"
tmpdir="${build}/clover/src"
preserve="false"
enabled="true"/>
</target>
<target name="clover.off" depends="clover.init" if="clover.present">
<!-- echo message="Clover is OFF!"/ -->
<clover-setup enabled="false"/>
</target>
<target name="clover.historypoint" depends="clover.init" if="clover.present">
<clover-historypoint historyDir="${build}/clover/history"/>
</target>
<target name="clover.report" depends="clover.on" if="clover.present">
<clover-report>
<current outfile="${build}/clover-report">
<format type="html"/>
</current>
<historical outfile="${build}/clover-history"
historyDir="${build}/clover/history">
<format type="html"/>
</historical>
</clover-report>
</target>
</project>