You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Wayne Fay <wa...@gmail.com> on 2009/05/03 16:21:05 UTC

Re: surefire plugin - test a specified method only instead of a specified class using the test parameter

> Do you know if surefire allows to explicitly test one method only? Is there
> a way to achive that at all?

Put each of your tests into different classes, with one method each.

Or write an Ant script or something to do this, and just let Maven do
the compile etc, then you run the test manually.

This really falls outside the scope of normal Maven usage which is why
its not supported.

Wayne

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


Re: surefire plugin - test a specified method only instead of a specified class using the test parameter

Posted by Frederic Camblor <fc...@gmail.com>.
Hi Kostas,

As Wayne answered, this would rather be a Junit question than a maven
question ;-)

With junit 3, you can override the "public void run(TestResult)" : inside
this method, the getName() method will return the current "test name" which
corresponds to the test method to execute for the current test case.

Then, you could be able to check a property of your choice defining the
FQN+method name to precisely execute (given to maven via
-Dtest.class.toExecute=foo.bar.MyTest.myTest)
=> you'll call super.run(TestResult) if and only if :
- your property is set and getClass().getName()+"."+getName() corresponds to
your current system property value
OR
- your property is not set

=> That implies a refactoring of every of your test classes in order to be
able to inherit from you super testcase class overriding the run(TestResult)
method.

Cheers,
Frederic


2009/5/3 Wayne Fay <wa...@gmail.com>

> > Do you know if surefire allows to explicitly test one method only? Is
> there
> > a way to achive that at all?
>
> Put each of your tests into different classes, with one method each.
>
> Or write an Ant script or something to do this, and just let Maven do
> the compile etc, then you run the test manually.
>
> This really falls outside the scope of normal Maven usage which is why
> its not supported.
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>