Hi all,
what you might also do is to write your testcases the JUnit 4 way
(whithout a suite() method,
without extending TestCase, without having your test methods named with
the "test" prefix)
and then write an additional class (which you simply can throw away in
the future)
which extends junit.framework.TestCase and provides a suite() method
returning
a JUnit4TestAdapter instance.
Yours
Stefan
-----Original Message-----
From: Cheng-Yang Tang <[EMAIL PROTECTED]>
To: Maven Users List <[email protected]>
Sent: Sat, 20 May 2006 13:44:14 +0100
Subject: RE: surefire 2.2 + JUnit4?
Hi Daun,
Thanks for your detailed explaination.
And yes, when I wrote the unit test in JUnit v3.8.1 way
everything works as expected.
Thanks very much
Louis
-----Original Message-----
From: Daun DeFrance [mailto:[EMAIL PROTECTED]
Sent: Fri 19/05/2006 17:01
To: Maven Users List
Subject: RE: surefire 2.2 + JUnit4?
Louis,
The only way I could get my JUnit4 tests to run is if they looked and
smelled like 3.8.1.
That is, my test had to extend TestCase (which overloads the static
import of Assert.*) and all my test methods had to begin with "test". I
also had the suite() method as you did below. With the proper JUnit4
dependency, my annotations and such compiled, but having to make my
JUnit4 test look like 3.8.1 eliminates all the benefits of writing v4
tests that will run in maven.
I downloaded the source for Surefire (trunk) and the junit provider is
pretty hardcoded to be 3.8.1. Well it looks for 3.8.1 syntax to
determine which tests to run. Until it is refactored to support JUnit 4
syntax, I don't think there's a real workaround (short of what I
mentioned above) to get it to work.
Does anyone have an idea on when this might be?
Best,
Daun
-----Original Message-----
From: Cheng-Yang Tang [mailto:[EMAIL PROTECTED]
Sent: Friday, May 19, 2006 4:39 AM
To: Maven Users List; Maven Users List
Subject: RE: surefire 2.2 + JUnit4?
I tried to modified the variable names so that those who willing to help
me out can understand my problem a bit easier. But it seems I missed
this one. Thanks for reminding me that. the "correct problem code"
should be as you pointed out (listed below). But it still doesn't work
as expected.
Louis
import org.junit.*;
import static org.junit.Assert.*;
import junit.framework.JUnit4TestAdapter;
public class MyTest {
private int i;
@Before public void runOnceBeforeAllTests()
{
i = 10;
}
@Test public void test4()
{
assertEquals(10, i);
}
public static junit.framework.Test suite()
{
return new JUnit4TestAdapter(MyTest.class);
}
}
-----Original Message-----
From: Jeffrey D. Brekke [mailto:[EMAIL PROTECTED]
Sent: Fri 19/05/2006 02:59
To: Maven Users List
Subject: Re: surefire 2.2 + JUnit4?
I don't know much about surefire, but it looks like the adapter is
pointing to the incorrect class? Should be MyTest.class?
Cheng-Yang Tang wrote:
[SNIPPED]
import org.junit.*;
import static org.junit.Assert.*;
import junit.framework.JUnit4TestAdapter;
public class MyTest {
private int i;
@Before public void runOnceBeforeAllTests()
{
i = 10;
}
@Test public void test4()
{
assertEquals(10, i);
}
public static junit.framework.Test suite()
{
return new JUnit4TestAdapter(WebServiceDispatcher.class);
}
}
--
=====================================================================
Jeffrey D. Brekke [EMAIL PROTECTED]
Wisconsin, USA [EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.bloglines.com/blog/jbrekke [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]
---------------------------------------------------------------------
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]
___________________________________________________
Try the New Netscape Mail Today!
Virtually Spam-Free | More Storage | Import Your Contact List
http://mail.netscape.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]