maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dennis Cook <dj_c...@yahoo.com>
Subject Re: JUnit4 test cases using @Before, @After fail test?
Date Wed, 23 May 2007 22:24:04 GMT
It looks like junit 3.8 is still being used.  The reason the method name prefix with 'test'
will be called by the older version.  The annotation is probably ignored.  Change the name
of the test method to another prefix, and I bet it will not be executed.

Alexander Sack <pisymbol@gmail.com> wrote: Btw, considering that @Test works, I'm pretty
positive I'm using 2.3 at this
point.  The only issue is the @Before seems to never get called.

Anyone run into this before?

-aps

On 5/23/07, Alexander Sack 
 wrote:
>
> Tom,
>
> Thanks sorry.  Yes I have specified in my root POM surefire-plugin 2.3 but
> not in my submodule one (I will try that right now).  The test ource is the
> one straight out of the FAQ regarding the colleciton, very simple test,
> passes on 3.8.1 but fails when I move up to 4.0 using the surefire
> plugin.  I'm using Junit-4.0.
>
> Is suppose to work?  The surefire report claims there is a null pointer:
>
> Here is my source:
>
> import static org.junit.Assert.* ;
>
> import java.util.ArrayList;
> import java.util.Collection;
>
> import org.junit.Before;
> import org.junit.Test;
>
> public class MyTest  {
>     private Collection c;
>
>     @Before
>     public void setUp() {
>         c = new ArrayList();
>     }
>
>     @Test
>     public void testSomeMethod() {
>         assertTrue(c.isEmpty());
>     }
> }
>
> Claims c is null which it isn't provided @Before runs (if I eliminate the
> method and put it in my testSomeMethod() it passes.  How can I tell what
> version of surefire I'm running?  The -e just says that test case has
> failed, etc stack.
>
> What am I doing wrong?  (man, I've used maven2 in all kinds of advanced
> ways and I feel retarded that this is not working!).
>
> -aps
>
> On 5/23/07, Tom Huybrechts  wrote:
> >
> > would you mind sharing some more information ? POMs, exceptions, test
> > source,  -X output ?
> >
> > As a general remark: make sure you have the latest surefire plugin...
> >
> > Tom
> >
> > On 5/23/07, Alexander Sack < pisymbol@gmail.com> wrote:
> > > Hey folks, is this a known issue that if I use @Before it will fail my
> > > test?  I searched some of the archives and saw some threads go by
> > about
> > > this.  Is this still an issue?
> > >
> > > Thanks!
> > >
> > > -aps
> > >
> > > --
> > > "What lies behind us and what lies in front of us is of little concern
> > to
> > > what lies within us." -Ralph Waldo Emerson
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> "What lies behind us and what lies in front of us is of little concern to
> what lies within us." -Ralph Waldo Emerson
>



-- 
"What lies behind us and what lies in front of us is of little concern to
what lies within us." -Ralph Waldo Emerson



Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message