ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Mirko.Zier...@nuernberger.de>
Subject .JUnit41 support in Ant 1.7 Beta
Date Tue, 05 Sep 2006 14:38:01 GMT
Hi,

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
fork="yes").


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 others:

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

---
Regards
Mirko





Hinweis:
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


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