You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Cheng-Yang Tang <Ch...@newcastle.ac.uk> on 2006/05/18 22:39:51 UTC

surefire 2.2 + JUnit4?

Hi,

I know the issue about how to use JUnit4 in Maven2 has been discussed for a while.
But the adapter method:

  public static junit.framework.Test suite() {
    return new JUnit4TestAdapter(SimpleTest.class);
  }

doesn't help much in my case.
I've heard that surefire2.2 may amend this.
However, after upgrading to sruefire2.2, this problem remains.
the test code are listed follow, which passed the JUnit test when I run it manually without maven
Can anyone help me with that?

Thanks in advance.

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(WebServiceDispatcher.class);
    }
}

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


RE: surefire 2.2 + JUnit4?

Posted by Cheng-Yang Tang <Ch...@newcastle.ac.uk>.
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:jbrekke@wi.rr.com]
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                                   jbrekke@wi.rr.com
Wisconsin,  USA                                     brekke@apache.org
                                                     ekkerbj@yahoo.com
http://www.bloglines.com/blog/jbrekke               ekkerbj@gmail.com


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



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


Re: surefire 2.2 + JUnit4?

Posted by "Jeffrey D. Brekke" <jb...@wi.rr.com>.
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                                   jbrekke@wi.rr.com
Wisconsin,  USA                                     brekke@apache.org
                                                     ekkerbj@yahoo.com
http://www.bloglines.com/blog/jbrekke               ekkerbj@gmail.com


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