Package org.junit.runner

Examples of org.junit.runner.JUnitCore.run()


    @Test
    public void newTestCount() {
        JUnitCore runner = new JUnitCore();
        MyListener listener = new MyListener();
        runner.addListener(listener);
        runner.run(Example.class);
        assertEquals(1, listener.testCount);
    }

    public static class ExampleTest extends TestCase {
        public void testEmpty() {
View Full Code Here


    @Test
    public void oldTestCount() {
        JUnitCore runner = new JUnitCore();
        MyListener listener = new MyListener();
        runner.addListener(listener);
        runner.run(ExampleTest.class);
        assertEquals(1, listener.testCount);
    }

    public static class NewExample {
        @Test
View Full Code Here

            public void testFinished(Description description) {
                wasRun = true;
            }
        };
        runner.addListener(listener);
        runner.run(NewExample.class);
        assertTrue(wasRun);
    }
}
View Full Code Here

    }

    @Test
    public void whenRunWithPreJava5DebugArgumentsTestShouldFail() {
        JUnitCore core = new JUnitCore();
        Result result = core.run(PreJava5DebugArgumentsTest.class);
        assertEquals("Should run the test", 1, result.getRunCount());
        assertEquals("Test should not have failed", 0, result.getFailureCount());
    }

    @Test
View Full Code Here

    }

    @Test
    public void whenRunWithPreJava5DebugArgumentsInReverseOrderTestShouldFail() {
        JUnitCore core = new JUnitCore();
        Result result = core
                .run(PreJava5DebugArgumentsReversedTest.class);
        assertEquals("Should run the test", 1, result.getRunCount());
        assertEquals("Test should not have failed", 0, result.getFailureCount());
    }
View Full Code Here

    }

    @Test
    public void whenRunWithPostJava5DebugArgumentsTestShouldFail() {
        JUnitCore core = new JUnitCore();
        Result result = core.run(PostJava5DebugArgumentsTest.class);
        assertEquals("Should run the test", 1, result.getRunCount());
        assertEquals("Test should not have failed", 0, result.getFailureCount());
    }

    @Test
View Full Code Here

    }

    @Test
    public void whenRunWithoutDebugFlagsTestShouldPass() {
        JUnitCore core = new JUnitCore();
        Result result = core.run(WithoutDebugArgumentsTest.class);
        assertEquals("Should run the test", 1, result.getRunCount());
        assertEquals("Test should have failed", 1, result.getFailureCount());
    }

}
View Full Code Here

            @Override
            public void testRunStarted(Description description) throws Exception {
                log += "second ";
            }
        });
        core.run(OneTest.class);
        assertEquals("first second ", log);
    }
}
View Full Code Here

    }

    @Test
    public void expected() {
        JUnitCore core = new JUnitCore();
        Result result = core.run(Expected.class);
        assertTrue(result.wasSuccessful());
    }

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

    }

    @Test
    public void noneThrown() {
        JUnitCore core = new JUnitCore();
        Result result = core.run(NoneThrown.class);
        assertFalse(result.wasSuccessful());
        String message = result.getFailures().get(0).getMessage();
        assertTrue(message.contains("Expected exception: java.lang.Exception"));
    }
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.