Search in sources :

Example 41 with TestResult

use of junit.framework.TestResult in project junit4 by junit-team.

the class ForwardCompatibilityTest method testBeforeAndAfterClass.

public void testBeforeAndAfterClass() {
    log = "";
    TestResult result = new TestResult();
    junit.framework.Test adapter = new JUnit4TestAdapter(BeforeClassTest.class);
    adapter.run(result);
    assertEquals("before class before test after before test after after class ", log);
}
Also used : TestResult(junit.framework.TestResult) JUnit4TestAdapter(junit.framework.JUnit4TestAdapter)

Example 42 with TestResult

use of junit.framework.TestResult in project junit4 by junit-team.

the class ForwardCompatibilityTest method testRunWithClass.

public void testRunWithClass() {
    wasRun = false;
    TestResult result = new TestResult();
    junit.framework.Test adapter = new JUnit4TestAdapter(NoTests.class);
    adapter.run(result);
    assertTrue(wasRun);
}
Also used : TestResult(junit.framework.TestResult) JUnit4TestAdapter(junit.framework.JUnit4TestAdapter)

Example 43 with TestResult

use of junit.framework.TestResult in project junit4 by junit-team.

the class ForwardCompatibilityPrintingTest method testErrorAdapted.

public void testErrorAdapted() {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    TestRunner runner = new TestRunner(new TestResultPrinter(new PrintStream(output)));
    String expected = expected(new String[] { ".E", "Time: 0", "Errors here", "", "FAILURES!!!", "Tests run: 1,  Failures: 0,  Errors: 1", "" });
    ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {

        @Override
        public void printErrors(TestResult result) {
            getWriter().println("Errors here");
        }
    };
    runner.setPrinter(printer);
    runner.doRun(new JUnit4TestAdapter(ATest.class));
    assertEquals(expected, output.toString());
}
Also used : PrintStream(java.io.PrintStream) ResultPrinter(junit.textui.ResultPrinter) TestRunner(junit.textui.TestRunner) TestResult(junit.framework.TestResult) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JUnit4TestAdapter(junit.framework.JUnit4TestAdapter)

Example 44 with TestResult

use of junit.framework.TestResult in project junit4 by junit-team.

the class ForwardCompatibilityPrintingTest method testError.

public void testError() {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    TestRunner runner = new TestRunner(new TestResultPrinter(new PrintStream(output)));
    String expected = expected(new String[] { ".E", "Time: 0", "Errors here", "", "FAILURES!!!", "Tests run: 1,  Failures: 0,  Errors: 1", "" });
    ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {

        @Override
        public void printErrors(TestResult result) {
            getWriter().println("Errors here");
        }
    };
    runner.setPrinter(printer);
    TestSuite suite = new TestSuite();
    suite.addTest(new TestCase() {

        @Override
        public void runTest() throws Exception {
            throw new Exception();
        }
    });
    runner.doRun(suite);
    assertEquals(expected, output.toString());
}
Also used : PrintStream(java.io.PrintStream) TestSuite(junit.framework.TestSuite) ResultPrinter(junit.textui.ResultPrinter) TestCase(junit.framework.TestCase) TestRunner(junit.textui.TestRunner) TestResult(junit.framework.TestResult) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 45 with TestResult

use of junit.framework.TestResult in project junit4 by junit-team.

the class JUnit4TestAdapterTest method doTest.

private static void doTest(Class<?> clazz) {
    // JUnit 4 runner:
    Result result = JUnitCore.runClasses(clazz);
    assertEquals(1, result.getRunCount());
    assertEquals(0, result.getFailureCount());
    assertEquals(0, result.getIgnoreCount());
    // JUnit 3 runner:
    TestResult testResult = new TestResult();
    new JUnit4TestAdapter(clazz).run(testResult);
    assertEquals(1, testResult.runCount());
    assertEquals(0, testResult.failureCount());
    assertEquals(Collections.emptyList(), Collections.list(testResult.errors()));
}
Also used : TestResult(junit.framework.TestResult) JUnit4TestAdapter(junit.framework.JUnit4TestAdapter) Result(org.junit.runner.Result) TestResult(junit.framework.TestResult)

Aggregations

TestResult (junit.framework.TestResult)108 TestSuite (junit.framework.TestSuite)33 Test (junit.framework.Test)19 JUnit4TestAdapter (junit.framework.JUnit4TestAdapter)17 TestCase (junit.framework.TestCase)14 TestFailure (junit.framework.TestFailure)12 Test (org.junit.Test)10 TestListener (junit.framework.TestListener)9 ArrayList (java.util.ArrayList)8 PrintStream (java.io.PrintStream)7 RepeatedTest (junit.extensions.RepeatedTest)7 Enumeration (java.util.Enumeration)6 Bundle (android.os.Bundle)5 HandlerThread (android.os.HandlerThread)5 ShellUiAutomatorBridge (com.android.uiautomator.core.ShellUiAutomatorBridge)5 Tracer (com.android.uiautomator.core.Tracer)5 UiAutomationShellWrapper (com.android.uiautomator.core.UiAutomationShellWrapper)5 AssertionFailedError (junit.framework.AssertionFailedError)5 IOException (java.io.IOException)4 Iterator (java.util.Iterator)4