Package junit.framework

Examples of junit.framework.TestCase


        wrapper.run(result);
        assertTrue(!result.wasSuccessful());
    }

    public void testRunningErrorsInTestSetup() {
        TestCase failure = new TestCase("failure") {
            @Override
            public void runTest() {
                fail();
            }
        };

        TestCase error = new TestCase("error") {
            @Override
            public void runTest() {
                throw new Error();
            }
        };
View Full Code Here


        // inner classes were bad...
        assertEquals("testCaseToString(junit.tests.framework.TestCaseTest)", toString());
    }

    public void testError() {
        TestCase error = new TestCase("error") {
            @Override
            protected void runTest() {
                throw new Error();
            }
        };
View Full Code Here

        verifyError(fails);
        assertTrue(fails.fTornDown);
    }

    public void testSetupFails() {
        TestCase fails = new TestCase("success") {
            @Override
            protected void setUp() {
                throw new Error();
            }
View Full Code Here

        };
        verifyError(fails);
    }

    public void testSuccess() {
        TestCase success = new TestCase("success") {
            @Override
            protected void runTest() {
            }
        };
        verifySuccess(success);
View Full Code Here

        };
        verifySuccess(success);
    }

    public void testFailure() {
        TestCase failure = new TestCase("failure") {
            @Override
            protected void runTest() {
                fail();
            }
        };
View Full Code Here

        verifyError(fails);
        assertTrue(fails.fTornDown);
    }

    public void testTearDownFails() {
        TestCase fails = new TestCase("success") {
            @Override
            protected void tearDown() {
                throw new Error();
            }
View Full Code Here

        assertEquals("running", failure.thrownException().getMessage());
    }

    public void testErrorTearingDownDoesntMaskErrorRunning() {
        final Exception running = new Exception("Running");
        TestCase t = new TestCase() {
            @Override
            protected void runTest() throws Throwable {
                throw running;
            }

            @Override
            protected void tearDown() throws Exception {
                throw new Error("Tearing down");
            }
        };
        try {
            t.runBare();
        } catch (Throwable thrown) {
            assertSame(running, thrown);
        }
    }
View Full Code Here

        assertTrue(result.failureCount() == 0);
        assertTrue(result.errorCount() == 0);
    }

    public void testNamelessTestCase() {
        TestCase t = new TestCase() {
        };
        TestResult result = t.run();
        assertEquals(1, result.failureCount());
    }
View Full Code Here

    public void addFailureDelegatesToNotifier() {
        Result result = new Result();
        RunListener listener = result.createListener();
        RunNotifier notifier = new RunNotifier();
        notifier.addFirstListener(listener);
        TestCase testCase = new TestCase() {
        };
        TestListener adaptingListener = new JUnit38ClassRunner(testCase)
                .createAdaptingListener(notifier);
        adaptingListener.addFailure(testCase, new AssertionFailedError());
        assertEquals(1, result.getFailureCount());
View Full Code Here


    public void testOneTest() {
        String expected = expected(new String[]{".", "Time: 0", "", "OK (1 test)", ""});
        TestSuite suite = new TestSuite();
        suite.addTest(new TestCase() {
            @Override
            public void runTest() {
            }
        });
        runner.doRun(suite);
View Full Code Here

TOP

Related Classes of junit.framework.TestCase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.