You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Grzegorz SÅ‚owikowski <gs...@op.pl> on 2006/02/18 18:39:44 UTC

JUnit 4.0

Hi All

JUnit 4.0 has just be released.

http://sourceforge.net/projects/junit

What I see is that it uses Java 5 annotations, and it's
not backward compatible with previous releases:

"The architecture of JUnit 4.0 is a substantial departure
 from that of earlier releases. Instead of tagging test classes
 by subclassing junit.framework.TestCase and tagging test methods
 by starting their name with "test", you now tag test methods
 with the @Test annotation."

It is not compatible with Maven's Surefire module, but maybe it is worth
some attention and future support (like TestNG).

Greg

Re: JUnit 4.0

Posted by Carlos Sanchez <ca...@apache.org>.
I've uploaded it to iBiblio so you can try it

On 2/19/06, Stefan Bodewig <bo...@apache.org> wrote:
> On Sun, 19 Feb 2006, Arnaud HERITIER <ah...@gmail.com> 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: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>


--
I could give you my word as a Spaniard.
No good. I've known too many Spaniards.
                             -- The Princess Bride

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


Re: JUnit 4.0

Posted by Kaare Nilsen <ka...@gmail.com>.
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 <bo...@apache.org> wrote:
> On Sun, 19 Feb 2006, Arnaud HERITIER <ah...@gmail.com> 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: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

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


Re: JUnit 4.0

Posted by Stefan Bodewig <bo...@apache.org>.
On Sun, 19 Feb 2006, Arnaud HERITIER <ah...@gmail.com> 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: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: JUnit 4.0

Posted by Arnaud HERITIER <ah...@gmail.com>.
Yes but It seems that JUnit 4 works only with Java 5 ??

Arnaud

On 2/18/06, Grzegorz SÅ‚owikowski <gs...@op.pl> wrote:
> Hi All
>
> JUnit 4.0 has just be released.
>
> http://sourceforge.net/projects/junit
>
> What I see is that it uses Java 5 annotations, and it's
> not backward compatible with previous releases:
>
> "The architecture of JUnit 4.0 is a substantial departure
>  from that of earlier releases. Instead of tagging test classes
>  by subclassing junit.framework.TestCase and tagging test methods
>  by starting their name with "test", you now tag test methods
>  with the @Test annotation."
>
> It is not compatible with Maven's Surefire module, but maybe it is worth
> some attention and future support (like TestNG).
>
> Greg
>
>