You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by js...@apache.org on 2003/09/19 18:26:50 UTC

cvs commit: maven/src/plugins-build/test plugin.jelly

jstrachan    2003/09/19 09:26:50

  Modified:    src/plugins-build/test/xdocs properties.xml changes.xml
               src/plugins-build/test plugin.jelly
  Log:
  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.
  
  Revision  Changes    Path
  1.7       +14 -0     maven/src/plugins-build/test/xdocs/properties.xml
  
  Index: properties.xml
  ===================================================================
  RCS file: /home/cvs/maven/src/plugins-build/test/xdocs/properties.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- properties.xml	23 Jun 2003 23:45:40 -0000	1.6
  +++ properties.xml	19 Sep 2003 16:26:50 -0000	1.7
  @@ -177,6 +177,20 @@
               </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>
  
  
  
  1.4       +10 -0     maven/src/plugins-build/test/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/maven/src/plugins-build/test/xdocs/changes.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- changes.xml	6 Aug 2003 08:23:43 -0000	1.3
  +++ changes.xml	19 Sep 2003 16:26:50 -0000	1.4
  @@ -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.
  
  
  
  1.18      +11 -3     maven/src/plugins-build/test/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/maven/src/plugins-build/test/plugin.jelly,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- plugin.jelly	19 Aug 2003 04:45:06 -0000	1.17
  +++ plugin.jelly	19 Sep 2003 16:26:50 -0000	1.18
  @@ -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>
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org