Package junit.framework

Examples of junit.framework.JUnit4TestAdapter.run()


    @Test
    public void ensureSuitesWorkWithForwardCompatibility() {
        junit.framework.Test test = new JUnit4TestAdapter(All.class);
        TestResult result = new TestResult();
        test.run(result);
        assertEquals(2, result.runCount());
    }

    @Test
    public void forwardCompatibilityWorksWithGetTests() {
View Full Code Here


    }

    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"));
    }
View Full Code Here

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

    public void testToStringSuite() {
        junit.framework.Test adapter = new JUnit4TestAdapter(NoTests.class);
View Full Code Here

    public void testCompatibility() {
        fLog = "";
        TestResult result = new TestResult();
        junit.framework.Test adapter = new JUnit4TestAdapter(NewTest.class);
        adapter.run(result);
        assertEquals("before test after ", fLog);
    }

    public void testToString() {
        JUnit4TestAdapter adapter = new JUnit4TestAdapter(NewTest.class);
View Full Code Here

    }

    public void testException() {
        TestResult result = new TestResult();
        junit.framework.Test adapter = new JUnit4TestAdapter(ErrorTest.class);
        adapter.run(result);
        assertEquals(exception, result.errors().nextElement().thrownException());
    }

    public void testNotifyResult() {
        JUnit4TestAdapter adapter = new JUnit4TestAdapter(ErrorTest.class);
View Full Code Here

            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());
    }

View Full Code Here

    }

    public void testNoException() {
        TestResult result = new TestResult();
        junit.framework.Test adapter = new JUnit4TestAdapter(NoExceptionTest.class);
        adapter.run(result);
        assertFalse(result.wasSuccessful());
    }

    public static class ExpectedTest {
        @Test(expected = Exception.class)
View Full Code Here

    }

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

    public static class UnExpectedExceptionTest {
        @Test(expected = Exception.class)
View Full Code Here

    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);
    }

    public static class ExceptionInBeforeTest {
        @Before
View Full Code Here

    }

    public void testExceptionInBefore() {
        TestResult result = new TestResult();
        junit.framework.Test adapter = new JUnit4TestAdapter(ExceptionInBeforeTest.class);
        adapter.run(result);
        assertEquals(1, result.errorCount());
    }

    public static class InvalidMethodTest {
        @BeforeClass
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.