maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Sack" <pisym...@gmail.com>
Subject Re: JUnit4 test cases using @Before, @After fail test?
Date Wed, 23 May 2007 22:46:59 GMT
Dennis, thanks for the tip.  Kinda obvious too...damn...

Okay, so can someone tell me what I need to do to FORCE it to use junit4?  I
specific junit-4.0 in my dependencies (scope is "test").  My parent dom of
the whole project has surefire plugin version set to 2.3.  I mean what else
do I have to do at this point?

-aps

On 5/23/07, Dennis Cook <dj_cook@yahoo.com> wrote:
>
> 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.3but
> > 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
>
>
>


-- 
"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, None, 0 bytes)
View raw message