maven-plugins/test/plugin.jelly
2003-01-24 03:44:26 +00:00

283 lines
9.4 KiB
XML

<?xml version="1.0"?>
<project xmlns:j="jelly:core"
xmlns:u="jelly:util"
xmlns:resources="resources"
xmlns:define="jelly:define">
<goal name="test"
description="Test the application"
prereqs="test:test"/>
<goal name="test:prepare-filesystem"
description="Create the needed directory structure">
<mkdir dir="${maven.test.dest}"/>
<mkdir dir="${maven.test.reportsDirectory}"/>
</goal>
<goal name="test:compile"
description="Compile the TestCases and TestSuites"
prereqs="java:compile,java:jar-resources,test:prepare-filesystem,test:test-resources">
<j:if test="${unitTestSourcesPresent == 'true'}">
<javac
destdir="${maven.test.dest}"
excludes="**/package.html"
debug="${maven.compile.debug}"
deprecation="${maven.compile.deprecation}"
optimize="${maven.compile.optimize}">
<j:if test="${context.getVariable('maven.test.source') != null}">
<setProperty name="source" value="${maven.test.source}" />
</j:if>
<classpath>
<pathelement path="${maven.build.dest}"/>
<path refid="maven.dependency.classpath"/>
<pathelement path="${plugin.getDependencyPath('junit')}"/>
</classpath>
<src>
<path refid="maven.test.compile.src.set"/>
</src>
</javac>
</j:if>
<j:if test="${!unitTestSourcesPresent}">
<echo>No test source files to compile.</echo>
</j:if>
</goal>
<goal name="test:test"
description="Test the application"
prereqs="test:compile">
<j:if test="${unitTestSourcesPresent == 'true'}">
<taskdef
name="junit"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"
/>
<junit printSummary="yes"
failureProperty="maven.test.failure"
fork="${maven.junit.fork}"
dir="${maven.junit.dir}">
<sysproperty key="basedir" value="${basedir}"/>
<u:tokenize var="listOfProperties" delim=" ">${maven.junit.sysproperties}</u:tokenize>
<j:forEach var="someProperty" items="${listOfProperties}">
<sysproperty key="${someProperty}" value="${context.findVariable(someProperty)}"/>
</j:forEach>
<formatter type="xml"/>
<formatter type="plain" usefile="${maven.junit.usefile}"/>
<classpath>
<path refid="maven.dependency.classpath"/>
<pathelement location="${maven.build.dest}"/>
<pathelement location="${maven.test.dest}"/>
<pathelement path="${plugin.getDependencyPath('junit')}"/>
</classpath>
<batchtest todir="${maven.test.reportsDirectory}">
<fileset dir="${pom.build.unitTestSourceDirectory}">
<j:forEach var="pat" items="${pom.build.unitTest.includes}">
<include name="${pat}"/>
</j:forEach>
<j:forEach var="pat" items="${pom.build.unitTest.excludes}">
<exclude name="${pat}"/>
</j:forEach>
<!-- KEEP ALL ABSTRACT TESTS FROM BEING RUN! -->
<exclude name="**/*AbstractTestCase.java"/>
</fileset>
</batchtest>
</junit>
<j:if test="${maven.test.failure}">
<j:set var="ignore__" value="${maven.test.failure.ignore}X"/>
<j:if test="${ignore__ == 'X'}">
<fail message="There were test failures."/>
</j:if>
</j:if>
</j:if>
<j:if test="${!unitTestSourcesPresent}">
<echo>No tests to run.</echo>
</j:if>
</goal>
<goal name="test:ui"
description="Starts the Swing TestRunner front end"
prereqs="test:compile">
<java classname="junit.swingui.TestRunner" fork="yes">
<sysproperty key="basedir" value="${basedir}"/>
<u:tokenize var="listOfProperties" delim=" ">${maven.junit.sysproperties}</u:tokenize>
<j:forEach var="someProperty" items="${listOfProperties}">
<sysproperty key="${someProperty}" value="${context.findVariable(someProperty)}"/>
</j:forEach>
<classpath>
<path refid="maven.dependency.classpath"/>
<pathelement location="${maven.build.dest}"/>
<pathelement location="${maven.test.dest}"/>
<pathelement path="${plugin.getDependencyPath('junit')}"/>
</classpath>
<arg value="-noloading"/>
</java>
</goal>
<goal name="test:single"
description="Execute a single test defined using the 'testcase' variable"
prereqs="test:compile">
<j:if test="${unitTestSourcesPresent == 'true'}">
<j:choose>
<j:when test="${empty(testcase)}">
<echo>
You must define the test case to run via -Dtestcase=classname
Example: maven -Dtestcase=MyTest test:single-test
</echo>
</j:when>
<j:otherwise>
<taskdef
name="junit"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"
/>
<junit printSummary="yes"
haltonfailure="yes"
haltonerror="yes"
fork="${maven.junit.fork}"
dir="${maven.junit.dir}">
<sysproperty key="basedir" value="${basedir}"/>
<u:tokenize var="listOfProperties" delim=" ">${maven.junit.sysproperties}</u:tokenize>
<j:forEach var="someProperty" items="${listOfProperties}">
<sysproperty key="${someProperty}" value="${context.findVariable(someProperty)}"/>
</j:forEach>
<formatter type="xml"/>
<formatter type="plain" usefile="false"/>
<formatter type="plain" usefile="true"/>
<classpath>
<path refid="maven.dependency.classpath"/>
<pathelement location="${maven.build.dest}"/>
<pathelement location="${maven.test.dest}"/>
<pathelement path="${plugin.getDependencyPath('junit')}"/>
</classpath>
<test name="${testcase}" todir="${maven.test.reportsDirectory}"/>
</junit>
</j:otherwise>
</j:choose>
</j:if>
<j:if test="${!unitTestSourcesPresent}">
<echo>No tests to run.</echo>
</j:if>
</goal>
<goal name="test:match"
description="Execute all the tests matching the given 'testmatch' variable"
prereqs="test:compile">
<j:if test="${unitTestSourcesPresent == 'true'}">
<j:choose>
<j:when test="${empty(testmatch)}">
<echo>
You must define the test case to run via -Dtestmatch=pattern
Example: maven -Dtestmatch=*Foo* test:match-test
</echo>
</j:when>
<j:otherwise>
<taskdef
name="junit"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"
/>
<junit printSummary="yes"
haltonfailure="yes"
haltonerror="yes"
fork="${maven.junit.fork}"
dir="${maven.junit.dir}">
<sysproperty key="basedir" value="${basedir}"/>
<u:tokenize var="listOfProperties" delim=" ">${maven.junit.sysproperties}</u:tokenize>
<j:forEach var="someProperty" items="${listOfProperties}">
<sysproperty key="${someProperty}" value="${context.findVariable(someProperty)}"/>
</j:forEach>
<formatter type="xml"/>
<formatter type="plain" usefile="false"/>
<formatter type="plain" usefile="true"/>
<classpath>
<path refid="maven.dependency.classpath"/>
<pathelement location="${maven.build.dest}"/>
<pathelement location="${maven.test.dest}"/>
<pathelement path="${plugin.getDependencyPath('junit')}"/>
</classpath>
<batchtest todir="${maven.test.reportsDirectory}">
<fileset dir="${pom.build.unitTestSourceDirectory}">
<include name="**/${testmatch}.java"/>
</fileset>
</batchtest>
</junit>
</j:otherwise>
</j:choose>
</j:if>
<j:if test="${!unitTestSourcesPresent}">
<echo>No tests to run.</echo>
</j:if>
</goal>
<goal name="test:single-test"
description="[deprecated] please use the test:single goal instead">
<echo>[deprecated] please use the test:single goal instead</echo>
<attainGoal name="test:single"/>
</goal>
<goal name="test:match-test"
description="[deprecated] please use the test:match goal instead">
<echo>[deprecated] please use the test:match goal instead</echo>
<attainGoal name="test:match"/>
</goal>
<!-- ================================================================== -->
<!-- T E S T R E S O U R C E S -->
<!-- ================================================================== -->
<goal name="test:test-resources"
description="Copy any resources that must be present for run tests"
prereqs="test:prepare-filesystem"
xmlns:resources="resources">
<j:if test="${unitTestSourcesPresent == 'true'}">
<j:if test="${!pom.build.unitTest.resources.isEmpty()}">
<resources:copy
resources="${pom.build.unitTest.resources}"
todir="${maven.test.dest}"
/>
</j:if>
</j:if>
</goal>
</project>