Message:

   The following issue has been closed.

   Resolver: Brett Porter
       Date: Fri, 7 Jan 2005 6:42 PM

honestly, I can't explain why this happens (probably differences in the 
classloader), but can assure you that it is not forking a new JVM for each 
instance. Run maven -X test, and then maven -X -Dmaven.junit.fork=yes and 
notice the difference.
---------------------------------------------------------------------
View the issue:
  http://jira.codehaus.org/browse/MPTEST-44

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: MPTEST-44
    Summary: JUnit fork is not working
       Type: Bug

     Status: Closed
   Priority: Major
 Resolution: INCOMPLETE

 Original Estimate: Unknown
 Time Spent: Unknown
  Remaining: Unknown

    Project: maven-test-plugin

   Assignee: 
   Reporter: Thomas Van de Velde

    Created: Mon, 11 Oct 2004 3:11 PM
    Updated: Fri, 7 Jan 2005 6:42 PM
Environment: Windows XP and RedHat 9.0

Description:
According to the test plugin's maven.junit.fork setting, Maven should not fork 
unit tests by default.  When executing a batch test, it does however fork test 
classes.  I have created the exact same scenario with ant and with Maven.  Ant 
loads my static block only once, Maven loads it with each test case.  Her's my 
test:

TEST CLASSES

public class BaseClass extends TestCase {
        
 static {
        System.out.println("Loading");
 }

}

public class Class1Test extends BaseClass {
        
        public void testNothing()
        {
                assertEquals(true,true);
        }

}

public class Class2Test extends BaseClass {
        
        public void testNothing()
        {
                assertEquals(true,true);
        }

}

public class Class3Test extends BaseClass {
        
        public void testNothing()
        {
                assertEquals(true,true);
        }

}

==================================================================

ANT

<project default="test">
<target name="test">
        <junit printsummary="yes" haltonfailure="no">
          <classpath>
            <pathelement path="bin"/>
          </classpath>

          <batchtest fork="no">
            <fileset dir="src">
              <include name="**/*Test*.java"/>
            </fileset>
          </batchtest>
        </junit>

</target>
</project>

test:
    [junit] Loading
    [junit] Running Class1Test
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0,01 sec

    [junit] Running Class2Test
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0 sec

    [junit] Running Class3Test
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0 sec


BUILD SUCCESSFUL

==================================================================

MAVEN

<project>
        <dependencies>
                <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <type>jar</type>
            <properties/>
        </dependency>
        </dependencies>
    <build>
        <sourceDirectory>${basedir}/src</sourceDirectory>
        <unitTestSourceDirectory>${basedir}/src</unitTestSourceDirectory>
        <unitTest>
            <includes>
                <include>**/*Test.java</include>
            </includes>
        </unitTest>
    </build>
</project>

test:test:
    [junit] Running Class1Test
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0,04 sec
Loading
    [junit] Running Class2Test
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0,01 sec
Loading
    [junit] Running Class3Test
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0,01 sec
BUILD SUCCESSFUL


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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

Reply via email to