Package org.junit.runner

Examples of org.junit.runner.Result$Listener



    @Test
    public void customRuleIsAppliedOnce() {
        ExampleTestWithCustomClassRule.counter.count = 0;
        Result result = JUnitCore.runClasses(ExampleTestWithCustomClassRule.class);
        assertTrue(result.wasSuccessful());
        assertEquals(1, ExampleTestWithCustomClassRule.counter.count);
    }
View Full Code Here



    @Test
    public void methodCustomRuleIsAppliedOnce() {
        MethodExampleTestWithCustomClassRule.counter.count = 0;
        Result result = JUnitCore.runClasses(MethodExampleTestWithCustomClassRule.class);
        assertTrue(result.wasSuccessful());
        assertEquals(1, MethodExampleTestWithCustomClassRule.counter.count);
    }
View Full Code Here

        }
    }

    public void testRunFailure() throws Exception {
        JUnitCore runner = new JUnitCore();
        Result result = runner.run(FailureTest.class);
        assertEquals(1, result.getRunCount());
        assertEquals(1, result.getFailureCount());
        assertEquals(AssertionError.class, result.getFailures().get(0).getException().getClass());
    }
View Full Code Here

        }
    }

    public void testSetupFailure() throws Exception {
        JUnitCore core = new JUnitCore();
        Result runner = core.run(SetupFailureTest.class);
        assertEquals(1, runner.getRunCount());
        assertEquals(1, runner.getFailureCount());
        assertEquals(Error.class, runner.getFailures().get(0).getException().getClass());
        assertFalse(run);
    }
View Full Code Here

        }
    }

    public void testTeardownFailure() throws Exception {
        JUnitCore core = new JUnitCore();
        Result runner = core.run(TeardownFailureTest.class);
        assertEquals(1, runner.getRunCount());
        assertEquals(1, runner.getFailureCount());
        assertEquals(Error.class, runner.getFailures().get(0).getException().getClass());
    }
View Full Code Here

        }
    }

    public void testTestAndTeardownFailure() throws Exception {
        JUnitCore core = new JUnitCore();
        Result runner = core.run(TestAndTeardownFailureTest.class);
        assertEquals(1, runner.getRunCount());
        assertEquals(2, runner.getFailureCount());
        assertThat(runner.getFailures().toString(), allOf(containsString("hereAfter"), containsString("inTest")));
    }
View Full Code Here

        }
    }

    public void testException() throws Exception {
        JUnitCore core = new JUnitCore();
        Result result = core.run(ExceptionTest.class);
        assertEquals(0, result.getFailureCount());
    }
View Full Code Here

    }

    @Test
    public void timeUnitTimeout() {
        HasGlobalTimeUnitTimeout.logger.setLength(0);
        Result result = JUnitCore.runClasses(HasGlobalTimeUnitTimeout.class);
        assertEquals(6, result.getFailureCount());
        assertThat(HasGlobalTimeUnitTimeout.logger.toString(), containsString("run1"));
        assertThat(HasGlobalTimeUnitTimeout.logger.toString(), containsString("run2"));
        assertThat(HasGlobalTimeUnitTimeout.logger.toString(), containsString("run3"));
        assertThat(HasGlobalTimeUnitTimeout.logger.toString(), containsString("run4"));
        assertThat(HasGlobalTimeUnitTimeout.logger.toString(), containsString("run5"));
View Full Code Here

        }
    }

    public void testExceptionNotThrown() throws Exception {
        JUnitCore core = new JUnitCore();
        Result result = core.run(NoExceptionTest.class);
        assertEquals(1, result.getFailureCount());
        assertEquals("Expected exception: java.lang.Error", result.getFailures().get(0).getMessage());
    }
View Full Code Here

    }

    @Test
    public void longTimeout() {
        HasGlobalLongTimeout.logger.setLength(0);
        Result result = JUnitCore.runClasses(HasGlobalLongTimeout.class);
        assertEquals(6, result.getFailureCount());
        assertThat(HasGlobalLongTimeout.logger.toString(), containsString("run1"));
        assertThat(HasGlobalLongTimeout.logger.toString(), containsString("run2"));
        assertThat(HasGlobalLongTimeout.logger.toString(), containsString("run3"));
        assertThat(HasGlobalLongTimeout.logger.toString(), containsString("run4"));
        assertThat(HasGlobalLongTimeout.logger.toString(), containsString("run5"));
View Full Code Here

TOP

Related Classes of org.junit.runner.Result$Listener

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.