Package org.junit.runner

Examples of org.junit.runner.Result


    }

    @Test
    public void successWithTimeout() throws Exception {
        JUnitCore core = new JUnitCore();
        Result result = core.run(SuccessWithTimeoutTest.class);
        assertEquals(1, result.getRunCount());
        assertEquals(0, result.getFailureCount());
    }
View Full Code Here


    }

    // when executing as JUnit 3, ignored tests are stripped out before execution
    @Test
    public void descriptionAndRunNotificationsAreConsistent() {
        Result result = JUnitCore.runClasses(CompatibilityTest.class);
        assertEquals(0, result.getIgnoreCount());

        Description description = Request.aClass(CompatibilityTest.class).getRunner().getDescription();
        assertEquals(0, description.getChildren().size());
    }
View Full Code Here

    }

    @Test
    public void suiteIsUsedWithJUnit4Classes() {
        wasRun = false;
        Result result = JUnitCore.runClasses(NewTestSuiteFails.class);
        assertEquals(1, result.getFailureCount());
        assertFalse(wasRun);
    }
View Full Code Here

    @Test
    public void makeSureSuiteNotUsedWithJUnit4Classes2() {
        wasRun = false;
        NewTestSuiteNotUsed.wasIgnoredRun = false;
        Result res = JUnitCore.runClasses(NewTestSuiteNotUsed.class);
        assertTrue(wasRun);
        assertFalse(NewTestSuiteNotUsed.wasIgnoredRun);
        assertEquals(0, res.getFailureCount());
        assertEquals(1, res.getRunCount());
        assertEquals(0, res.getIgnoreCount());
    }
View Full Code Here

    @Ignore("was breaking gump")
    @Test
    public void timeoutFailure() throws Exception {
        JUnitCore core = new JUnitCore();
        Result result = core.run(TimeoutFailureTest.class);
        assertEquals(1, result.getRunCount());
        assertEquals(1, result.getFailureCount());
        assertEquals(InterruptedException.class, result.getFailures().get(0).getException().getClass());
    }
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

                "The class rule should have been applied because the test method is ignored!");
    }

    private void runClassAndVerifyNoFailures(Class<?> klass,
            String testFailureDescription) {
        Result result = JUnitCore.runClasses(klass);
        analyseResult(result, testFailureDescription);
    }
View Full Code Here

    }

    @Test
    public void infiniteLoop() throws Exception {
        JUnitCore core = new JUnitCore();
        Result result = core.run(InfiniteLoopTest.class);
        assertEquals(1, result.getRunCount());
        assertEquals(1, result.getFailureCount());
        Throwable exception = result.getFailures().get(0).getException();
        assertTrue(exception.getMessage().contains("test timed out after 100 milliseconds"));
    }
View Full Code Here

    }
   
    @Test
    public void stalledThreadAppearsInStackTrace() throws Exception {
        JUnitCore core = new JUnitCore();
        Result result = core.run(InfiniteLoopTest.class);
        assertEquals(1, result.getRunCount());
        assertEquals(1, result.getFailureCount());
        Throwable exception = result.getFailures().get(0).getException();
        assertThat(stackForException(exception), containsString("infiniteLoop")); // Make sure we have the stalled frame on the stack somewhere
    }
View Full Code Here

    }

    @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();
        assertThat(exception[0].getMessage(), containsString("test timed out after 100 milliseconds"));
        assertThat(stackForException(exception[0]), containsString("Thread.join"));
        assertThat(exception[1].getMessage(), containsString("Appears to be stuck in thread timeout-thr2"));
    }
View Full Code Here

TOP

Related Classes of org.junit.runner.Result

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.