You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jl...@apache.org on 2013/04/17 08:39:51 UTC

svn commit: r1468762 - in /ant/easyant/plugins/trunk/junit: module.ivy src/main/resources/junit.ant src/test/antunit/junit-test.xml

Author: jlboudart
Date: Wed Apr 17 06:39:50 2013
New Revision: 1468762

URL: http://svn.apache.org/r1468762
Log:
Disable tests if junit is not found on classpath

Modified:
    ant/easyant/plugins/trunk/junit/module.ivy
    ant/easyant/plugins/trunk/junit/src/main/resources/junit.ant
    ant/easyant/plugins/trunk/junit/src/test/antunit/junit-test.xml

Modified: ant/easyant/plugins/trunk/junit/module.ivy
URL: http://svn.apache.org/viewvc/ant/easyant/plugins/trunk/junit/module.ivy?rev=1468762&r1=1468761&r2=1468762&view=diff
==============================================================================
--- ant/easyant/plugins/trunk/junit/module.ivy (original)
+++ ant/easyant/plugins/trunk/junit/module.ivy Wed Apr 17 06:39:50 2013
@@ -15,7 +15,7 @@
    limitations under the License.
 -->
 <ivy-module version="2.0" xmlns:ea="http://www.easyant.org">
-    <info organisation="org.apache.easyant.plugins" module="junit" revision="0.9">
+    <info organisation="org.apache.easyant.plugins" module="junit" revision="0.10">
         <extends organisation="org.apache.easyant.plugins" module="parent-plugin" revision="0.1" location="../parent.ivy" />
         <description>
             This module provides junit tests compilation and execution feature.
@@ -34,4 +34,4 @@
     <publications>
         <artifact type="ant" />
     </publications>
-</ivy-module>
\ No newline at end of file
+</ivy-module>

Modified: ant/easyant/plugins/trunk/junit/src/main/resources/junit.ant
URL: http://svn.apache.org/viewvc/ant/easyant/plugins/trunk/junit/src/main/resources/junit.ant?rev=1468762&r1=1468761&r2=1468762&view=diff
==============================================================================
--- ant/easyant/plugins/trunk/junit/src/main/resources/junit.ant (original)
+++ ant/easyant/plugins/trunk/junit/src/main/resources/junit.ant Wed Apr 17 06:39:50 2013
@@ -14,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 -->
-<project name="org.apache.easyant.plugins#junit" xmlns:ea="antlib:org.apache.easyant">
+<project name="org.apache.easyant.plugins#junit" xmlns:ea="antlib:org.apache.easyant" xmlns:ac="antlib:net.sf.antcontrib">
     <ea:core-version requiredrevision="[0.9,+]" />
 
     <ea:plugin module="abstract-test" revision="0.9" />
@@ -32,6 +32,24 @@
             description="Run integration tests in a separate VM. (true/false)" />
         <ea:parameter property="test.integration.run.jvmargs" default=""
             description="Extra parameters to pass to the integration test JVM, for example to enable debugging" />
+
+        <condition property="junit.available">
+            <or>
+                <!-- Junit 3 -->
+                <available classname="junit.framework.Test" classpathref="compile.test.classpath" />
+                <!-- Junit 4 -->
+                <available classname="org.junit.Test" classpathref="compile.test.classpath" />
+            </or>
+        </condition>
+        <ac:if>
+            <isfalse value="${junit.available}" />
+            <ac:then>
+                <echo level="debug"
+                    message="tests will be disabled as junit is not available in your project. Check your project dependencies if you want to run tests" />
+                <property name="skip.test" value="true" />
+                <property name="skip.test.integration" value="true" />
+            </ac:then>
+        </ac:if>
     </target>
 
     <macrodef name="junit-test">
@@ -90,4 +108,4 @@
         <fail if="test.integration.failed"
             message="At least one integration test has failed. See logs in ${target.test.xml} or report in ${target.test.html}" />
     </target>
-</project>
\ No newline at end of file
+</project>

Modified: ant/easyant/plugins/trunk/junit/src/test/antunit/junit-test.xml
URL: http://svn.apache.org/viewvc/ant/easyant/plugins/trunk/junit/src/test/antunit/junit-test.xml?rev=1468762&r1=1468761&r2=1468762&view=diff
==============================================================================
--- ant/easyant/plugins/trunk/junit/src/test/antunit/junit-test.xml (original)
+++ ant/easyant/plugins/trunk/junit/src/test/antunit/junit-test.xml Wed Apr 17 06:39:50 2013
@@ -14,73 +14,90 @@
    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="" />
-    </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>
\ No newline at end of file
+<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>