FileDocCategorySizeDatePackage
JUnitTestRunnerTest.javaAPI DocApache Ant 1.706417Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs.optional.junit

JUnitTestRunnerTest

public class JUnitTestRunnerTest extends TestCase
Small testcase for the runner, tests are very very very basics. They must be enhanced with time.

Fields Summary
Constructors Summary
public JUnitTestRunnerTest(String name)

        super(name);
    
Methods Summary
protected org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunnerTest$TestRunnercreateRunner(java.lang.Class clazz)

        return new TestRunner(new JUnitTest(clazz.getName()), true, true, true);
    
public static voidmain(java.lang.String[] args)

        junit.textui.TestRunner.run(JUnitTestRunnerTest.class);
    
public voidtestInvalidSuite()

        TestRunner runner = createRunner(InvalidSuiteTestCase.class);
        runner.run();
        String error = runner.getFormatter().getError();
        assertEquals(error, JUnitTestRunner.ERRORS, runner.getRetCode());
        assertTrue(error, error.indexOf("thrown on purpose") != -1);
    
public voidtestInvalidTestCase()

        TestRunner runner = createRunner(InvalidTestCase.class);
        runner.run();
        // On junit3 this is a FAILURE, on junit4 this is an ERROR
        int ret = runner.getRetCode();
        if (ret != JUnitTestRunner.FAILURES && ret != JUnitTestRunner.ERRORS) {
            fail("Unexpected result " + ret + " from junit runner");
        }
        // JUNIT3 test
        //assertEquals(error, JUnitTestRunner.FAILURES, runner.getRetCode());
        //@fixme as of now does not report the original stacktrace.
        //assertTrue(error, error.indexOf("thrown on purpose") != -1);
    
public voidtestNoSuite()

        TestRunner runner = createRunner(NoSuiteTestCase.class);
        runner.run();
        assertEquals(runner.getFormatter().getError(), JUnitTestRunner.SUCCESS, runner.getRetCode());
    
public voidtestNoTestCase()

        TestRunner runner = createRunner(NoTestCase.class);
        runner.run();
        // On junit3 this is a FAILURE, on junit4 this is an ERROR
        int ret = runner.getRetCode();
        
        if (ret != JUnitTestRunner.FAILURES && ret != JUnitTestRunner.ERRORS) {
            fail("Unexpected result " + ret + " from junit runner");
        }
        // JUnit3 test
        //assertEquals(runner.getFormatter().getError(), JUnitTestRunner.FAILURES, runner.getRetCode());
    
public voidtestSuite()

        TestRunner runner = createRunner(SuiteTestCase.class);
        runner.run();
        assertEquals(runner.getFormatter().getError(), JUnitTestRunner.SUCCESS, runner.getRetCode());