Hi all..
Though i did not test this using surefire (yet), I am almost certain
that it would work..
the followng testcode, and notice the inner suite() method.
package no.objectware.test.junit4;
import junit.framework.JUnit4TestAdapter;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class Junit4Test {
@BeforeClass
public static void doSomeInitialSetup() {
System.out.println("Before a clazz");
}
@Before
public void beforeATest(){
System.out.println("\tBefore a testMethod");
}
@Test
public void doATest(){
System.out.println("\t\tYohoo");
}
@Test
public void anoterTest(){
System.out.println("\t\tAnother test");
}
@After
public void afterATest(){
System.out.println("\tAfter a testMethod");
}
@AfterClass
public static void doSomeCleanup() {
System.out.println("After a clazz");
}
/**
* Wrap the new junit4 testcase in a 3.x style suite
* to be recognized by eclipse runner and maven surefire.
* @return
*/
public static junit.framework.Test suite() {
return new JUnit4TestAdapter(Junit4Test.class);
}
}
Of course you would need java 5, but hey.. who doesn't ;)
/Kaare
On 19/02/06, Stefan Bodewig <[EMAIL PROTECTED]> wrote:
> On Sun, 19 Feb 2006, Arnaud HERITIER <[EMAIL PROTECTED]> wrote:
>
> > Yes but It seems that JUnit 4 works only with Java 5 ??
>
> It requires Java 5 to compile and annotations for JUnit 4 style
> tests. JUnit 3 style tests are still supported (so you can run your
> old tests against JUnit 4) and don't require Java 5 at runtime. There
> also is a compatibility layer that allows JUnit 4 style tests to run
> against JUnit 3 test runners (like Ant's) which would again require
> Java 5 at runtime.
>
> I did some tests with Ant's JUnit task when JUnit 4 stabilized in
> CVS. I guess much of it applies to Maven as well.
>
> http://stefan.samaflost.de/blog/en/Apache/Ant/junit4_and_ant.writeback
> http://stefan.samaflost.de/blog/en/Apache/Ant/junit4_and_ant_no_problem.html
>
> Stefan
>
> ---------------------------------------------------------------------
> 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]