Package org.junit.runner

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


    }

    @Test
    public void timeoutFailureMultithreaded() throws Exception {
        JUnitCore core = new JUnitCore();
        Result result = core.run(InfiniteLoopWithStuckThreadTest.class);
        assertEquals(1, result.getRunCount());
        assertEquals(2, result.getFailureCount());
        Throwable exception[] = new Throwable[2];
        for (int i = 0; i < 2; i++)
            exception[i] = result.getFailures().get(i).getException();
View Full Code Here


    }

    @Test
    public void timeoutFailureMultithreadedStuckInMain() throws Exception {
        JUnitCore core = new JUnitCore();
        Result result = core.run(InfiniteLoopStuckInMainThreadTest.class);
        assertEquals(1, result.getRunCount());
        assertEquals(1, result.getFailureCount());
        Throwable exception = result.getFailures().get(0).getException();
        assertThat(exception.getMessage(), containsString("test timed out after 100 milliseconds"));
        assertThat(exception.getMessage(), not(containsString("Appears to be stuck")));
View Full Code Here

    }

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

    private static class TimeoutSubclass extends Timeout {
View Full Code Here

    }

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

            @Override
            public void testAssumptionFailure(Failure failure) {
                assumptionFailures++;
            }
        });
        core.run(HasFailingAssumption.class);

        assertThat(assumptionFailures, is(1));
    }

    public static class HasPassingAssumption {
View Full Code Here

            @Override
            public void testAssumptionFailure(Failure failure) {
                failures.add(failure);
            }
        });
        core.run(clazz);
        return failures;
    }
}
View Full Code Here

public class ResultTest extends TestCase {

    public void testRunFailureResultCanBeSerialised() throws Exception {
        JUnitCore runner = new JUnitCore();
        Result result = runner.run(AnnotationTest.FailureTest.class);
        assertResultSerializable(result);
    }

    public void testRunSuccessResultCanBeSerialised() throws Exception {
        JUnitCore runner = new JUnitCore();
View Full Code Here

        assertResultSerializable(result);
    }

    public void testRunSuccessResultCanBeSerialised() throws Exception {
        JUnitCore runner = new JUnitCore();
        Result result = runner.run(Success.class);
        assertResultSerializable(result);
    }

    private void assertResultSerializable(Result result) throws IOException, ClassNotFoundException {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
View Full Code Here

    }

    private static Result runTest(Class<?> test) {
        simulateTimePassing(1L);
        JUnitCore junitCore = new JUnitCore();
        return junitCore.run(Request.aClass(test).getRunner());
    }

    private static void simulateTimePassing(long millis) {
        fakeTimeNanos += TimeUnit.MILLISECONDS.toNanos(millis);
    }
View Full Code Here

    @org.junit.Test
    public void ensureTestIsRun() {
        JUnitCore runner = new JUnitCore();
        run = false; // Have to explicitly set run here because the runner might independently run OneTest above
        runner.run(All.class);
        assertTrue(run);
    }

    @org.junit.Test
    public void correctTestCount() throws Throwable {
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.