junit works if your mojo is going to be completely wired up by your tests.

abstractmojotestcase, as documented on the wiki, is probably the
easiest way to test a mojo, as it utilises the same technique for
populating fields and you can use a small pom-like file to describe
the configuration

I wouldn't use plexus test case directly - the abstract mojo test case
builds on top of it for the same scenarios.

the embedder is useful if you need to test the lifecycle interaction
of several mojos, but it is slower because it is a full maven run.

- Brett

On 4/20/06, Rinku <[EMAIL PROTECTED]> wrote:
> Mojo testing is something I have been wanting to raise on this list for
> last couple of days as well ;-)
>
> Following is the only reference available, I have been digging into
> sources last couple of days to code up mojo tests.
>
> http://docs.codehaus.org/display/MAVEN/Maven+Plugin+Harness
>
> Apparently there are different posssible approaches to unit testing
> Mojos/Plugins. This is what I found:
> a) Simple JUnit test case.
> b) extend PlexusTestCase (see Continuum IT sources)
> c) extend AbstractMojoTestCase (see maven-install-plugin sources).
> d) use Maven Embedder, Plexus Commandline utils (see under
> maven-eclipse-plugin sources - master project test)
> e) use JMockObjects (see maven-clover-plugin or Cargo Maven extension
> sources).
>
> It would be great if Maven devs (or others) can chip in notes/thoughts
> on these approaches and what might be the appropriate scenarios for each
> approach :-) -  I am happy to document them!
>
> Cheers,
> Rahul
>
>
>
> ----- Original Message -----
> From: "Michael Meyer" <[EMAIL PROTECTED]>
> To: "Maven Users List" <[email protected]>
> Sent: Thursday, April 20, 2006 5:04 AM
> Subject: [M203] Writing tests for Plugins (Java Mojos)
>
>
> > Hi,
> > is there any documentation around about writing tests for maven
> > plugins?
> > I saw that some plugins subclass org.codehaus.plexus.PlexusTestCase
> > for theire tests but a simple example of a "typical" maven plugin test
> > would be helpful.
> >
> > michael
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to