I should point out that my @Test method does, in fact, execute:
[junit] at com.mycompany.myapp.bus.TestThing.getSessionTest (TestThingjava:47) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:585)[junit] at org.junit.internal.runners.TestMethodRunner.executeMethodBody (TestMethodRunner.java:99) [junit] at org.junit.internal.runners.TestClassRunner.run (TestClassRunner.java:52) [junit] at junit.framework.JUnit4TestAdapter.run (JUnit4TestAdapter.java:32) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run (JUnitTestRunner.java:366)
I've built Ant from the 2006.08.25 snapshot, and added some logging code to the JUnitTestRunner taskdef so see if I could figure out what's going on. As near as I can tell, it's setting up a JUnit4TestAdapter and using that to determine that it's running against JUnit4. The problems is, according to the Ant 1.7 docs for JUnit,
It also works with JUnit 4.0, including "pure" JUnit 4 tests using only annotations and no JUnit4TestAdapter.So that seems to me that it should not use JUnit4TestAdapter. My build target looks like this:
<target name="test" depends="build, compile-test" description="Run unit tests">
<junit printsummary="on" fork="false" haltonfailure="false" failureproperty="tests.failed" showoutput="true" filtertrace="false"> <jvmarg value="-ea"/> <jvmarg value="-esa"/> <classpath refid="test.classpath"/> <formatter type="brief" usefile="false"/> <batchtest fork="yes" todir="${test.reports}"> <fileset dir="${testsrc}"> <include name="**/*Test*.java"/> </fileset> </batchtest> </junit> </target> And my test looks like this: // // Third-party Imports // import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.*; public class TestThing { @Test public void getSessionTest() { System.err.println("getSessionTest()"); } }Perhaps this is a bug in JUnit--I have yet to try running the test outside of Ant. But if anyone can shed any light, I'd appreciate it. Thanks!
-- Rick
smime.p7s
Description: S/MIME cryptographic signature