A patch so that the test plugin can use the test classes directory - rather than just the test source code directory - for searching for unit test cases to run.
The default behaviour remains unchanged - however this new feature allows other languages which compile down to bytecode - like Groovy - to be used and found by the default unit test run. This mechanism could also be useful if other test classes are copied or code generated into the target/test-classes directory etc. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114042 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
1 parent
d7e5d050cb
commit
f2643277b2
3 files changed
+35
-3
No files matched your search
+11
-3
@@ -20,6 +20,11 @@
|
||||
description="Compile the TestCases and TestSuites"
|
||||
prereqs="java:compile,java:jar-resources,test:prepare-filesystem,test:test-resources">
|
||||
|
||||
<j:set var="maven.test.searchdir" value="${maven.test.dest}"/>
|
||||
<j:if test="${context.getVariable('maven.test.search.classdir') == null}">
|
||||
<j:set var="maven.test.searchdir" value="${pom.build.unitTestSourceDirectory}"/>
|
||||
</j:if>
|
||||
|
||||
<j:if test="${unitTestSourcesPresent == 'true'}">
|
||||
|
||||
<javac
|
||||
@@ -86,6 +91,7 @@
|
||||
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}">
|
||||
@@ -104,7 +110,7 @@
|
||||
<pathelement path="${plugin.getDependencyPath('junit')}"/>
|
||||
</classpath>
|
||||
<batchtest todir="${maven.test.reportsDirectory}">
|
||||
<fileset dir="${pom.build.unitTestSourceDirectory}">
|
||||
<fileset dir="${maven.test.searchdir}">
|
||||
<j:forEach var="pat" items="${pom.build.unitTest.includes}">
|
||||
<include name="${pat}"/>
|
||||
</j:forEach>
|
||||
@@ -241,6 +247,8 @@
|
||||
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"
|
||||
/>
|
||||
|
||||
<echo>Searching directory ${maven.test.searchdir}</echo>
|
||||
|
||||
<junit printSummary="yes"
|
||||
haltonfailure="yes"
|
||||
haltonerror="yes"
|
||||
@@ -269,8 +277,8 @@
|
||||
</classpath>
|
||||
|
||||
<batchtest todir="${maven.test.reportsDirectory}">
|
||||
<fileset dir="${pom.build.unitTestSourceDirectory}">
|
||||
<include name="**/${testmatch}.java"/>
|
||||
<fileset dir="${maven.test.searchdir}">
|
||||
<include name="**/${testmatch}.*"/>
|
||||
</fileset>
|
||||
</batchtest>
|
||||
|
||||
|
||||
@@ -6,6 +6,16 @@
|
||||
</properties>
|
||||
|
||||
<body>
|
||||
<release version="1.5" date="in CVS">
|
||||
<action dev="jstrachan" type="fix">
|
||||
You can now specify whether the source (java) or classes (class) files
|
||||
are searched when using the test plugin via the property:
|
||||
maven.test.search.classdir. It defaults to use (java) to preserve
|
||||
backwards compatibilty. Using (class) allows you to work with alternative
|
||||
languages that compile to bytecode like
|
||||
<a href="http://groovy.codehaus.org/>Groovy</a>
|
||||
</action>
|
||||
</release>
|
||||
<release version="1.4" date="in CVS">
|
||||
<action dev="evenisse" type="fix">
|
||||
Check if unitTest tag is present in pom before copy resources.
|
||||
|
||||
@@ -177,6 +177,20 @@ basedir=${basedir}
|
||||
</source>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.test.search.classdir</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Use this property to specify that JUnit should search the test classes directory
|
||||
rather than the source directory. This allows for test cases to be written in other
|
||||
languages such as Groovy which generate bytecode that can then be used by this plugin.
|
||||
Sample :
|
||||
<source><![CDATA[
|
||||
maven.test.search.classdir=true
|
||||
]]>
|
||||
</source>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
</body>
|
||||
|
||||
Reference in new issue
Block a user