Posted By:
Anonymous
Posted On:
Sunday, March 26, 2006 03:40 PM
I am using JUnit 4.0, and having great difficulty getting my tests to run from Ant 1.6.5. I guessed that the junit runner in the Ant distribution is geared to JUnit 3.x, and finally discovered through trial and error that the only way to let my tests be found was by by declaring inport org.junit.Test; // annotation class public final class MyTestCase extends junit.framework.TestCase { . . . @Test public void testSomething() { . . .} } In other words, extends TestCase is required, in the manner of JUnit 3.x, and the use of the @Test annotation is ineffective (for the Ant junit task). Following the suggestion in junit-4.0/doc/faq/faq.htm
More>>
I am using JUnit 4.0, and having great difficulty getting my tests to run from Ant 1.6.5. I guessed that the junit runner in the Ant distribution is geared to JUnit 3.x, and finally discovered through trial and error that the only way to let my tests be found was by by declaring
inport org.junit.Test; // annotation class
public final class MyTestCase
extends junit.framework.TestCase
{
. . .
@Test public void testSomething() { . . .}
}
In other words,
extends TestCase
is required, in the manner of JUnit 3.x, and the use of the
@Test
annotation is ineffective (for the Ant
junit
task).
Following the suggestion in junit-4.0/doc/faq/faq.htm
public static junit.framework.Test suite() {
return new junit.framework.JUnit4TestAdapter(MyTestCase.class);
}
does not have any discernible effect.
If i neglect to extend
TestCase
, then what i get from Ant is
[junit] FAILED
[junit] No tests found in MyTestCase
[junit] junit.framework.AssertionFailedError: No tests found in MyTestCase
The test runs OK from the command line, without extending
TestCase
.
java -classpath ".:junit-4.0.jar" org.junit.runner.JUnitCore MyTestCase
JUnit version 4.0
.
Time: 0
OK (1 test)
What am i not getting about using JUnit 4.0 with Ant?
<<Less