Search in sources :

Example 61 with TestResult

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

the class RepeatedTestTest method testRepeatedOnce.

public void testRepeatedOnce() {
    Test test = new RepeatedTest(fSuite, 1);
    assertEquals(2, test.countTestCases());
    TestResult result = new TestResult();
    test.run(result);
    assertEquals(2, result.runCount());
}
Also used : Test(junit.framework.Test) RepeatedTest(junit.extensions.RepeatedTest) RepeatedTest(junit.extensions.RepeatedTest) TestResult(junit.framework.TestResult)

Example 62 with TestResult

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

the class TextFeedbackTest method testFailure.

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

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

        @Override
        public void runTest() {
            throw new AssertionFailedError();
        }
    });
    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) TestResult(junit.framework.TestResult) AssertionFailedError(junit.framework.AssertionFailedError)

Example 63 with TestResult

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

the class ForwardCompatibilityTest method testInvalidMethod.

public void testInvalidMethod() {
    TestResult result = new TestResult();
    junit.framework.Test adapter = new JUnit4TestAdapter(InvalidMethodTest.class);
    adapter.run(result);
    assertEquals(1, result.errorCount());
    TestFailure failure = result.errors().nextElement();
    assertTrue(failure.exceptionMessage().contains("Method shouldBeStatic() should be static"));
}
Also used : TestFailure(junit.framework.TestFailure) TestResult(junit.framework.TestResult) JUnit4TestAdapter(junit.framework.JUnit4TestAdapter)

Example 64 with TestResult

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

the class ForwardCompatibilityTest method testNotifyResult.

public void testNotifyResult() {
    JUnit4TestAdapter adapter = new JUnit4TestAdapter(ErrorTest.class);
    TestResult result = new TestResult();
    final StringBuffer log = new StringBuffer();
    result.addListener(new TestListener() {

        public void startTest(junit.framework.Test test) {
            log.append(" start ").append(test);
        }

        public void endTest(junit.framework.Test test) {
            log.append(" end ").append(test);
        }

        public void addFailure(junit.framework.Test test, AssertionFailedError t) {
            log.append(" failure ").append(test);
        }

        public void addError(junit.framework.Test test, Throwable e) {
            log.append(" error " + test);
        }
    });
    adapter.run(result);
    String testName = String.format("error(%s)", ErrorTest.class.getName());
    assertEquals(String.format(" start %s error %s end %s", testName, testName, testName), log.toString());
}
Also used : TestResult(junit.framework.TestResult) TestListener(junit.framework.TestListener) JUnit4TestAdapter(junit.framework.JUnit4TestAdapter) AssertionFailedError(junit.framework.AssertionFailedError)

Example 65 with TestResult

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

the class ForwardCompatibilityTest method testExpected.

public void testExpected() {
    TestResult result = new TestResult();
    junit.framework.Test adapter = new JUnit4TestAdapter(ExpectedTest.class);
    adapter.run(result);
    assertTrue(result.wasSuccessful());
}
Also used : TestResult(junit.framework.TestResult) JUnit4TestAdapter(junit.framework.JUnit4TestAdapter)

Aggregations

TestResult (junit.framework.TestResult)80 TestSuite (junit.framework.TestSuite)25 JUnit4TestAdapter (junit.framework.JUnit4TestAdapter)15 TestCase (junit.framework.TestCase)13 Test (junit.framework.Test)11 TestFailure (junit.framework.TestFailure)8 RepeatedTest (junit.extensions.RepeatedTest)7 TestListener (junit.framework.TestListener)7 Test (org.junit.Test)7 PrintStream (java.io.PrintStream)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 ResultPrinter (junit.textui.ResultPrinter)4 Enumeration (java.util.Enumeration)3 TestSetup (junit.extensions.TestSetup)3 AssertionFailedError (junit.framework.AssertionFailedError)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2