|
Hi All,
I go on with development of Xdocle/Junit
component.
There are two cases when you can use it:
1. To generate suite classes for specified packages. The suite
class groups tests for the package and subpackages. The fragment of build.xml
file looks like this:
==================================================================
<target name="junitdoclet"
depends="prepare">
<taskdef
name="junitdoclet"
classname="xdoclet.junit.JunitTask" classpathref="" />
<junitdoclet
sourcepath="${src.dir}" destdir="${generated.src.dir}" mergedir="merge"> <classpath refid="class.path"/> <classpath refid="xdoclet.class.path"/> <fileset
dir="${src.dir}">
<include name="**/*.java" /> </fileset> <generateSuite
inPackage="com.zzz.test"/>
<generateSuite inPackage="com.zzz.test.user"/>
</junitdoclet>
</target>
==============================================================
The other case which I just finished is that suite classes
will be generated for a package
and all its subpackages. The build.xml fragment will look like
this:
==============================================================
<target name="junitdocletall"
depends="prepare">
<taskdef
name="junitdoclet"
classname="xdoclet.junit.JunitTask" classpathref="" />
<junitdoclet
sourcepath="${src.dir}" destdir="${generated.src.dir}" mergedir="merge" forAllPackagesStarting="com.zzz.test"> <classpath refid="class.path"/> <classpath refid="xdoclet.class.path"/> <fileset
dir="${src.dir}">
<include name="**/*.java" /> </fileset>
</junitdoclet>
</target>
======================================================================= Just in case, Dmitri, if you did not commit the changes, here
is my requested change to SubTask:
=======================================================================
/**
* Iterates over all packages loaded by javadoc. Subsequent calls to * forAllClasses will only iterate over the classes in the current package. * * @param template The body of the block tag * @param attributes The attributes of the template tag * @exception BuildException Throw to stop the build process * @doc:tag type="block" * @doc:param name="abstract" optional="true" * values="true,false" description="If true then accept abstract classes * also; otherwise don't." * @doc:param name="type" optional="true" description="For all * classes by the type." * @doc:param name="extent" optional="true" * values="concrete-type,superclass,hierarchy" description="Specifies the * extent of the type search. If concrete-type then only check the * concrete type, if superclass then check also superclass, if hierarchy * then search the whole hierarchy and find if the class is of the * specified type. Default is hierarchy." * @doc:param name="starting" optional="true" * description="Iterates packages which are either this package or its * subclasses" */ public void forAllPackages( String template, Properties attributes ) throws BuildException { ClassDoc[] classes = root.classes(); SortedSet packages = new TreeSet(); for( int i = 0; i < classes.length; i++
)
{ if( attributes.getProperty( "starting" ) == null || classes[i].containingPackage().name().startsWith( attributes.getProperty( "starting" ) ) ) { packages.add( classes[i].containingPackage() ); } } PackageDoc cur_package = null;
for( Iterator packageIterator =
packages.iterator(); packageIterator.hasNext();
)
{ cur_package = ( PackageDoc ) packageIterator.next(); setCurrentPackage( cur_package ); generate( template ); } // restore current package to null, so subsequent class iterations can // perform outside the context of a current packages setCurrentPackage( null ); } ======================================================================== The new versions of the files are attached with this
email.
The new features I am going to add are the
following:
1. Implement a tag @junit:ignore, which would prevent the test
case to be added to any suite.
2. If the test case has suite() method it should be used
rather than generating new TestSuite class.
Any more feature requests?
Thanks!
Michael.
|
- [Xdoclet-devel] Re: xdoclet/junit: request for cvs commit Michael Larionov
- [Xdoclet-devel] Re: xdoclet/junit: request for cvs c... Dmitri Colebatch
JunitTask.java