Alexander Sack wrote:
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?

I have this in my parent pom and @Before works for me:

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.3.1</version>
      <scope>test</scope>
    </dependency>

IIRC early versions of junit 4 did not call @Before on subclasses.
So if by any chance your MyTest class is a subclass of e.g. TestCase
and this was really a bug in junit 4.0 then this might be the cause.

FWIW: I noticed yesterday taht the junit4 runner in eclipse 3.2.2 does not call @Before on subclases of TestCase.

maybe mvn -X ... gives more information?

best regards
Bernd

-aps

On 5/23/07, Dennis Cook <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 < [EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> "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







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to