DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40708>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40708

           Summary: Running JUnit 4 tests with AspectJ and fork=No causes
                    exception
           Product: Ant
           Version: 1.7.0Beta2
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P3
         Component: Optional Tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: [EMAIL PROTECTED]


The classes to be tested are Singletons written with AspectJ and Java 1.5. The
test-classes are pure Junit 4 tests with anotations and without 
JUnit4TestAdapter.

If I run the ant script with fork="no" I get the exception: "No runnable 
methods".
But if I run the ant script with the attribute fork="yes" the junit testcase can
be executed and I get an "AssertionFailedError".

Here is the junit task of my ant-script:

<junit printsummary="on" haltonerror="off"  >
        <formatter type="xml" />
        <classpath>
         <pathelement path="${classes.dir}" />
                <pathelement path="${test.classes.dir}" />
                <pathelement path="${ant.home}/lib/" />
        </classpath>
        <classpath refid="project.classpath" />

        <batchtest fork="no" todir="${test.report.dir}" >
                <fileset dir="${test.source.dir}">
                        <include name="**/*Test*.java" />
                        <exclude name="**/*Mock*.java" />
                </fileset>
        </batchtest>
</junit>


Here is the test-case:

public class SingletonTest
{
  @Test 
  public void createSingleton()
  {
    TestMock1 s1 = new TestMock1();
    TestMock1 s2 = new TestMock1();
    
    assertEquals(s1, s2);
    assertTrue(s1.getInvocationTime() == s2.getInvocationTime());
    
    TestMock2 s3 = new TestMock2();
    TestMock2 s4 = new TestMock2();
    
    assertEquals(s3, s4);
    assertTrue(s3.getInvocationTime() == s4.getInvocationTime());
    assertNotSame(s1, s3);
  }
}

and one mock object representatively for the other:

@Singleton
public class TestMock1
{
  protected Long invocationTime = System.currentTimeMillis();
  
  /**
   * R&#65533;ckgabe der Instanziierungszeit
   * @return long - Timestamp
   */
  public Long getInvocationTime()
  {
    return invocationTime; 
  }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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

Reply via email to