Search in sources :

Example 11 with TestCase

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

the class TextFeedbackTest method testError.

public void testError() {
    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) TestResult(junit.framework.TestResult)

Example 12 with TestCase

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

the class TextFeedbackTest method testTwoTests.

public void testTwoTests() {
    String expected = expected(new String[] { "..", "Time: 0", "", "OK (2 tests)", "" });
    TestSuite suite = new TestSuite();
    suite.addTest(new TestCase() {

        @Override
        public void runTest() {
        }
    });
    suite.addTest(new TestCase() {

        @Override
        public void runTest() {
        }
    });
    runner.doRun(suite);
    assertEquals(expected, output.toString());
}
Also used : TestSuite(junit.framework.TestSuite) TestCase(junit.framework.TestCase)

Example 13 with TestCase

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

the class TestCaseTest method testNamelessTestCase.

public void testNamelessTestCase() {
    TestCase t = new TestCase() {
    };
    TestResult result = t.run();
    assertEquals(1, result.failureCount());
}
Also used : TestCase(junit.framework.TestCase) TestResult(junit.framework.TestResult)

Example 14 with TestCase

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

the class TestListenerTest method testStartStop.

public void testStartStop() {
    TestCase test = new TestCase("noop") {

        @Override
        public void runTest() {
        }
    };
    test.run(fResult);
    assertEquals(1, fStartCount);
    assertEquals(1, fEndCount);
}
Also used : TestCase(junit.framework.TestCase)

Example 15 with TestCase

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

the class TestListenerTest method testFailure.

public void testFailure() {
    TestCase test = new TestCase("noop") {

        @Override
        public void runTest() {
            fail();
        }
    };
    test.run(fResult);
    assertEquals(1, fFailureCount);
    assertEquals(1, fEndCount);
}
Also used : TestCase(junit.framework.TestCase)

Aggregations

TestCase (junit.framework.TestCase)129 TestSuite (junit.framework.TestSuite)36 Test (junit.framework.Test)22 TestListener (junit.framework.TestListener)17 TestResult (junit.framework.TestResult)13 ArrayList (java.util.ArrayList)12 InvocationTargetException (java.lang.reflect.InvocationTargetException)10 AssertionFailedError (junit.framework.AssertionFailedError)10 Constructor (java.lang.reflect.Constructor)8 Enumeration (java.util.Enumeration)6 Context (android.content.Context)5 PackageManager (android.content.pm.PackageManager)5 ResolveInfo (android.content.pm.ResolveInfo)5 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 Field (java.lang.reflect.Field)5 HashSet (java.util.HashSet)5