Search in sources :

Example 61 with JUnitCore

use of org.junit.runner.JUnitCore in project junit4 by junit-team.

the class AnnotationTest method testTwoTests.

public void testTwoTests() throws Exception {
    count = 0;
    tests = new HashSet<Object>();
    JUnitCore runner = new JUnitCore();
    runner.run(TwoTests.class);
    assertEquals(2, count);
    assertEquals(2, tests.size());
}
Also used : JUnitCore(org.junit.runner.JUnitCore)

Example 62 with JUnitCore

use of org.junit.runner.JUnitCore in project junit4 by junit-team.

the class AnnotationTest method testTeardownFailure.

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());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult)

Example 63 with JUnitCore

use of org.junit.runner.JUnitCore in project junit4 by junit-team.

the class AnnotationTest method testErrorInBeforeClass.

public void testErrorInBeforeClass() throws Exception {
    run = false;
    JUnitCore core = new JUnitCore();
    Result result = core.run(ErrorInBeforeClass.class);
    assertFalse(run);
    assertEquals(1, result.getFailureCount());
    Description description = result.getFailures().get(0).getDescription();
    assertEquals(ErrorInBeforeClass.class.getName(), description.getDisplayName());
}
Also used : Description(org.junit.runner.Description) JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult)

Example 64 with JUnitCore

use of org.junit.runner.JUnitCore in project junit4 by junit-team.

the class AnnotationTest method testExceptionNotThrown.

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());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) PrintableResult.testResult(org.junit.experimental.results.PrintableResult.testResult)

Example 65 with JUnitCore

use of org.junit.runner.JUnitCore in project junit4 by junit-team.

the class AnnotationTest method testSetup.

public void testSetup() throws Exception {
    JUnitCore runner = new JUnitCore();
    runner.run(SetupTest.class);
    assertTrue(run);
}
Also used : JUnitCore(org.junit.runner.JUnitCore)

Aggregations

JUnitCore (org.junit.runner.JUnitCore)173 Result (org.junit.runner.Result)104 Test (org.junit.Test)88 Request (org.junit.runner.Request)33 Failure (org.junit.runner.notification.Failure)24 PrintableResult.testResult (org.junit.experimental.results.PrintableResult.testResult)22 RunListener (org.junit.runner.notification.RunListener)17 Description (org.junit.runner.Description)16 ArrayList (java.util.ArrayList)14 TestResult (junit.framework.TestResult)14 TextListener (org.junit.internal.TextListener)12 Runner (org.junit.runner.Runner)9 RandomizedRunner (com.carrotsearch.randomizedtesting.RandomizedRunner)7 TestSuiteModel (com.google.testing.junit.runner.model.TestSuiteModel)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 OutputStream (java.io.OutputStream)5 CategoryFilter (org.junit.experimental.categories.Categories.CategoryFilter)5 File (java.io.File)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 InOrder (org.mockito.InOrder)4