blob: ade30ddc9cc80b379598de707b20b98d76dda1d3 [file] [log] [blame]
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.
-->
<project name="org.apache.easyant.plugins;junit-test" xmlns:au="antlib:org.apache.ant.antunit" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:ea="antlib:org.apache.easyant">
<!-- Import your plugin -->
<property name="target" value="target/test-antunit" />
<!-- configure easyant in current project -->
<ea:configure-easyant-ivy-instance />
<!-- import our local plugin -->
<ea:import-test-module moduleIvy="../../../module.ivy" sourceDirectory="../../main/resources" />
<!-- Defines a setUp / tearDown (before each test) that cleans the environnement -->
<target name="clean" description="remove stale build artifacts before / after each test">
<delete dir="${basedir}" includeemptydirs="true">
<include name="**/target/**" />
<include name="**/lib/**" />
</delete>
</target>
<!--FIXME: junit targets get executed as they are prefixed by "test" -->
<target name="setUp" depends="clean">
<ivy:settings id="project.ivy.instance" />
<ivy:cachepath pathid="compile.test.classpath" file="sample-module.ivy" settingsRef="project.ivy.instance" />
<mkdir dir="${target}/test/classes" />
<mkdir dir="${target}/integration-test/classes" />
<javac srcdir="src/test/java" destdir="${target}/test/classes" classpathref="compile.test.classpath" />
<javac srcdir="src/integration-test/java" destdir="${target}/integration-test/classes" classpathref="compile.test.classpath" />
</target>
<target name="tearDown" depends="clean" />
<target name="test-junit:init" depends="junit:init">
<au:assertPropertyEquals name="test.run.forkmode" value="perTest" />
<au:assertPropertyEquals name="test.run.fork" value="true" />
<au:assertPropertyEquals name="test.run.jvmargs" value="" />
<au:assertPropertyEquals name="test.integration.run.forkmode" value="perTest" />
<au:assertPropertyEquals name="test.integration.run.fork" value="true" />
<au:assertPropertyEquals name="test.integration.run.jvmargs" value="" />
<au:assertFalse>
<isset property="skip.test" />
</au:assertFalse>
<au:assertFalse>
<isset property="skip.test.integration" />
</au:assertFalse>
<au:assertLogDoesntContain text="tests will be disabled as junit is not available in your project. Check your project dependencies if you want to run tests" level="debug" />
</target>
<target name="prepare-disabled-tests">
<!-- create an empty classpath -->
<ea:path pathid="compile.test.classpath" overwrite="true" />
</target>
<target name="test-junit:init-disabled-tests" depends="prepare-disabled-tests,junit:init">
<au:assertTrue>
<isset property="skip.test" />
</au:assertTrue>
<au:assertTrue>
<isset property="skip.test.integration" />
</au:assertTrue>
<au:assertLogContains text="tests will be disabled as junit is not available in your project. Check your project dependencies if you want to run tests" level="debug" />
</target>
<target name="test-junit:test" depends="-junit:test">
<au:assertFileExists file="${target.test.xml}" />
<au:assertFileExists file="${test.run.dir}" />
</target>
<target name="test-junit:integration-test" depends="-junit:integration-test">
<au:assertFileExists file="${target.test.xml}" />
<au:assertFileExists file="${test.integration.run.dir}" />
</target>
<target name="configure-plugin">
<property name="test.mode.run" value="true" />
<property name="test.run.failonerror" value="false" />
</target>
<target name="test-junit:run" depends="configure-plugin,junit:run">
<au:assertLogContains text="At least one test has failed. See logs in ${target.test.xml} for details or use the report target to run the test with a report" level="error" />
</target>
<target name="test-junit:run-integration" depends="configure-plugin,junit:run-integration">
<au:assertLogContains text="At least one integration test has failed. See logs in ${target.test.xml} for details or use the report target to run the test with a report" level="error" />
</target>
<target name="test-junit:report" depends="junit:report">
<!--TODO: add this missing test case -->
</target>
</project>