Package org.junit.runner

Examples of org.junit.runner.JUnitCore


        assertThat(exception[1].getMessage(), containsString("Appears to be stuck in thread timeout-thr2"));
    }

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

        }
    }

    @Test
    public void beforeClassShouldNotRunWhenAllTestsAreFiltered() {
        Result result = new JUnitCore().run(Request.classes(
                BeforeClassWithFilteredTest.class, HasUnfilteredTest.class)
                .filterWith(CategoryFilter.exclude(FilteredTests.class)));
        analyseResult(
                result,
                "BeforeClass should not have been executed because the test method is filtered!");
View Full Code Here

    private static int assumptionFailures = 0;

    @Test
    public void failedAssumptionsCanBeDetectedByListeners() {
        assumptionFailures = 0;
        JUnitCore core = new JUnitCore();
        core.addListener(new RunListener() {
            @Override
            public void testAssumptionFailure(Failure failure) {
                assumptionFailures++;
            }
        });
        core.run(HasFailingAssumption.class);

        assertThat(assumptionFailures, is(1));
    }
View Full Code Here

     * Helper method that runs tests on <code>clazz</code> and returns any
     * {@link Failure} objects that were {@link AssumptionViolatedException}s.
     */
    private static List<Failure> runAndGetAssumptionFailures(Class<?> clazz) {
        final List<Failure> failures = new ArrayList<Failure>();
        final JUnitCore core = new JUnitCore();
        core.addListener(new RunListener() {
            @Override
            public void testAssumptionFailure(Failure failure) {
                failures.add(failure);
            }
        });
        core.run(clazz);
        return failures;
    }
View Full Code Here

import org.junit.tests.running.methods.AnnotationTest;

public class ResultTest extends TestCase {

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

        Result result = runner.run(AnnotationTest.FailureTest.class);
        assertResultSerializable(result);
    }

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

        simulateTimePassing(1L);
    }

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

    @Test
    public void oneTimeSetup() throws Exception {
        count = 0;
        Runner runner = Request.method(OneTimeSetup.class, "one").getRunner();
        Result result = new JUnitCore().run(runner);

        assertEquals(1, count);
        assertEquals(1, result.getRunCount());
    }
View Full Code Here

TOP

Related Classes of org.junit.runner.JUnitCore

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.