Package junit.framework

Examples of junit.framework.JUnit4TestAdapter


        adapter.run(result);
        assertEquals("before test after ", fLog);
    }

    public void testToString() {
        JUnit4TestAdapter adapter = new JUnit4TestAdapter(NewTest.class);
        junit.framework.Test test = adapter.getTests().get(0);
        assertEquals(String.format("test(%s)", NewTest.class.getName()), test.toString());
    }
View Full Code Here


        junit.framework.Test test = adapter.getTests().get(0);
        assertEquals(String.format("test(%s)", NewTest.class.getName()), test.toString());
    }

    public void testUseGlobalCache() {
        JUnit4TestAdapter adapter1 = new JUnit4TestAdapter(NewTest.class);
        JUnit4TestAdapter adapter2 = new JUnit4TestAdapter(NewTest.class);
        assertSame(adapter1.getTests().get(0), adapter2.getTests().get(0));
    }
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());
    }
View Full Code Here

        adapter.run(result);
        assertEquals(exception, result.errors().nextElement().thrownException());
    }

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

            String className = classFileToName(classFile);
            try {
                final Class<TestCase> c = (Class<TestCase>) sysClassLoader.loadClass(className);
                if (!c.isInterface() && !Modifier.isAbstract(c.getModifiers())) {
                    LOGGER.info("Added " + className);
                    suite.addTest(new JUnit4TestAdapter(c));
                    counter++;
                }
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
View Full Code Here

    public UtilTest() {
    }

    public static junit.framework.Test suite() {
        return new JUnit4TestAdapter(UtilTest.class);
    }
View Full Code Here

TOP

Related Classes of junit.framework.JUnit4TestAdapter

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.