FileDocCategorySizeDatePackage
JUnitTaskTest.javaAPI DocApache Ant 1.705724Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.taskdefs.optional.junit

JUnitTaskTest

public class JUnitTaskTest extends org.apache.tools.ant.BuildFileTest

Fields Summary
Constructors Summary
public JUnitTaskTest(String name)
Constructor for the JUnitTaskTest object

        super(name);
    
Methods Summary
private voidassertNoPrint(java.lang.String result, java.lang.String where)

        assertTrue(where + " '" + result + "' must not contain print statement",
                   result.indexOf("print to System.") == -1);
    
private voidassertOutput()

        FileReader inner = new FileReader(getProject()
                                          .resolveFile("testlog.txt"));
        BufferedReader reader = new BufferedReader(inner);
        try {
            String line = reader.readLine();
            assertEquals("Testsuite: org.apache.tools.ant.taskdefs.optional.junit.Printer",
                         line);
            line = reader.readLine();
            assertNotNull(line);
            assertTrue(line.startsWith("Tests run: 1, Failures: 0, Errors: 0, Time elapsed:"));
            line = reader.readLine();
            assertEquals("------------- Standard Output ---------------",
                         line);
            assertPrint(reader.readLine(), "static", "out");
            assertPrint(reader.readLine(), "constructor", "out");
            assertPrint(reader.readLine(), "method", "out");
            line = reader.readLine();
            assertEquals("------------- ---------------- ---------------",
                         line);
            line = reader.readLine();
            assertEquals("------------- Standard Error -----------------",
                         line);
            assertPrint(reader.readLine(), "static", "err");
            assertPrint(reader.readLine(), "constructor", "err");
            assertPrint(reader.readLine(), "method", "err");
            line = reader.readLine();
            assertEquals("------------- ---------------- ---------------",
                         line);
            line = reader.readLine();
            assertEquals("", line);
            line = reader.readLine();
            assertNotNull(line);
            assertTrue(line.startsWith("Testcase: testNoCrash took "));
        } finally {
            inner.close();
        }
    
private voidassertPrint(java.lang.String line, java.lang.String from, java.lang.String to)

        String search = from + " print to System." + to;
        assertEquals(search, line);
    
private voidassertResultFileExists(java.lang.String classNameFragment, java.lang.String ext)

        assertTrue("result for " + classNameFragment + "Test" + ext + " exists",
                   getProject().resolveFile("out/TEST-org.apache.tools.ant."
                                            + "taskdefs.optional.junit."
                                            + classNameFragment + "Test" + ext)
                   .exists());
    
private voidassertResultFilesExist(java.lang.String target, java.lang.String extension)

        executeTarget(target);
        assertResultFileExists("JUnitClassLoader", extension);
        assertResultFileExists("JUnitTestRunner", extension);
        assertResultFileExists("JUnitVersionHelper", extension);
    
public voidsetUp()
The JUnit setup method

        configureProject("src/etc/testcases/taskdefs/optional/junit.xml");
    
public voidtearDown()
The teardown method for JUnit

        executeTarget("cleanup");
    
public voidtestBatchTestForkOnceCustomFormatter()

        assertResultFilesExist("testBatchTestForkOnceCustomFormatter", "foo");
    
public voidtestBatchTestForkOnceExtension()
Bugzilla Report 32973

        assertResultFilesExist("testBatchTestForkOnceExtension", ".foo");
    
public voidtestBatchTestForkOnceToDir()

        assertResultFilesExist("testBatchTestForkOnceToDir", ".xml");
    
public voidtestCrash()

       expectPropertySet("crash", "crashed");
    
public voidtestForkedCapture()

        getProject().setProperty("fork", "true");
        testNonForkedCapture();
        // those would fail because of the way BuildFileTest captures output
        assertNoPrint(getOutput(), "output");
        assertNoPrint(getError(), "error output");
        assertOutput();
    
public voidtestNoCrash()

       expectPropertyUnset("nocrash", "crashed");
    
public voidtestNoTimeout()

       expectPropertyUnset("notimeout", "timeout");
    
public voidtestNonForkedCapture()

        executeTarget("capture");
        assertNoPrint(getLog(), "log");
        assertNoPrint(getFullLog(), "debug log");
    
public voidtestTimeout()

       expectPropertySet("timeout", "timeout");