Hello:
  Sorry I am new to Maven and Surefire but I think my problem should be
posted to this group.  

I like many others am having a problem running Junit 4.4 test cases when
running maven.  I have not seen a definitive solution to the problem.

I can manually execute the following class and the test fails in the
setUp() method as expected.  When I run this with maven, the @before
method is never called.    I have seen a couple of different postings in
various places that indicate that indicate that is fixed with the code
changes for running TestNG.  I have also seen some postings that
indicate that this problem is not fixed and may never get fixed.

My question is should maven and surefire be able to run this class and
fail in the setUp() method as coded?  
Is there something I can change in my pom to make it run in surefire as
a 4.4 Junit?


Currently using Maven 2.1.0, surefire 2.4.3 
   
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <forkMode>always</forkMode>
            <redirectTestOutputToFile>true</redirectTestOutputToFile>
            <!-- Add the following argument to skip the tests
-Dmaven.test.skip=true -->
            <includes>
              <include>**/*Tests.java</include>
            </includes>
            
        </configuration>
      </plugin>


package support;

import junit.framework.Assert;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.internal.runners.JUnit4ClassRunner;
import org.junit.runner.RunWith;



@RunWith(JUnit4ClassRunner.class)
public class FooTests {
  
   @Before
  public void setUp() throws Exception {
  Assert.fail("foo");
  }
  
   @After
  public void tearDown() throws Exception {
  }
  
  @Test
  public void testFoo() {
  }
  
  public static void main(String[] args) {
    org.junit.runner.JUnitCore.main("support.FooTests");
  }
}

Reply via email to