ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject JUnit4.1 support in Ant 1.7 Beta
Date Tue, 05 Sep 2006 13:33:49 GMT

I have some problems in testing java classes with Junit 4.1 and Ant 1.7 Beta.

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 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".

Can anyone help me finding out, how to start the ant script without VM-forking (attribute

Here is the junit task of my ant-script:

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

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

Here is the test-case:

public class SingletonTest
  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 others:

public class TestMock1
  protected Long invocationTime = System.currentTimeMillis();
   * Rückgabe der Instanziierungszeit
   * @return long - Timestamp
  public Long getInvocationTime()
    return invocationTime; 


Mit freundlichen Grüßen 

Mirko Zieroth 

Ostendstraße 100, 90334 Nürnberg 
Telefon (09 11) 5 31-26 88, Fax 0911-531-81-2688

Der Inhalt dieser E-Mail ist ausschließlich für den bezeichneten Empfänger bestimmt und
kann vertrauliche Informationen enthalten. Wenn Sie nicht der Empfänger dieser E-Mail oder
dessen Vertreter sind, dann senden Sie bitte die E-Mail an den Absender zurück (Antwort-Funktion
bzw. reply email). Entfernen Sie bitte danach die Nachricht aus Ihrem System.
This e-mail message including any attachments may contain privileged or confidential information
and is for the sole use of the intended recipient(s). If you are not the intended recipient,
please immediately return this e-mail message to the sender by reply e-mail, delete the original
message and destroy all copies thereof.
MSW 5.1

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message