Search in sources :

Example 1 with JUnitCore

use of org.junit.runner.JUnitCore in project buck by facebook.

the class JUnitRunner method run.

@Override
public void run() throws Throwable {
    Level stdOutLogLevel = Level.INFO;
    Level stdErrLogLevel = Level.WARNING;
    String unparsedStdOutLogLevel = System.getProperty(STD_OUT_LOG_LEVEL_PROPERTY);
    String unparsedStdErrLogLevel = System.getProperty(STD_ERR_LOG_LEVEL_PROPERTY);
    if (unparsedStdOutLogLevel != null) {
        stdOutLogLevel = Level.parse(unparsedStdOutLogLevel);
    }
    if (unparsedStdErrLogLevel != null) {
        stdErrLogLevel = Level.parse(unparsedStdErrLogLevel);
    }
    for (String className : testClassNames) {
        final Class<?> testClass = Class.forName(className);
        List<TestResult> results = new ArrayList<>();
        RecordingFilter filter = new RecordingFilter();
        if (mightBeATestClass(testClass)) {
            JUnitCore jUnitCore = new JUnitCore();
            Runner suite = new Computer().getSuite(createRunnerBuilder(), new Class<?>[] { testClass });
            Request request = Request.runner(suite);
            request = request.filterWith(filter);
            jUnitCore.addListener(new TestListener(results, stdOutLogLevel, stdErrLogLevel));
            jUnitCore.run(request);
        }
        // Combine the results with the tests we filtered out
        List<TestResult> actualResults = combineResults(results, filter.filteredOut);
        writeResult(className, actualResults);
    }
}
Also used : Runner(org.junit.runner.Runner) JUnitCore(org.junit.runner.JUnitCore) ArrayList(java.util.ArrayList) Computer(org.junit.runner.Computer) Request(org.junit.runner.Request) Level(java.util.logging.Level)

Example 2 with JUnitCore

use of org.junit.runner.JUnitCore in project jna by java-native-access.

the class GDI32UtilTest method main.

public static void main(String[] args) {
    JUnitCore jUnitCore = new JUnitCore();
    jUnitCore.run(GDI32UtilTest.class);
}
Also used : JUnitCore(org.junit.runner.JUnitCore)

Example 3 with JUnitCore

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

the class CategoriesAndParameterizedTest method runsTestMethodWithCategory.

@Test
public void runsTestMethodWithCategory() {
    Result result = new JUnitCore().run(SuiteWithParameterizedTestWithMethodWithCategory.class);
    assertEquals(2, result.getRunCount());
    assertEquals(0, result.getFailureCount());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 4 with JUnitCore

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

the class DisableOnDebugTest method whenRunWithPreJava5DebugArgumentsTestShouldFail.

@Test
public void whenRunWithPreJava5DebugArgumentsTestShouldFail() {
    JUnitCore core = new JUnitCore();
    Result result = core.run(PreJava5DebugArgumentsTest.class);
    assertEquals("Should run the test", 1, result.getRunCount());
    assertEquals("Test should not have failed", 0, result.getFailureCount());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 5 with JUnitCore

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

the class DisableOnDebugTest method whenRunWithPostJava5DebugArgumentsTestShouldFail.

@Test
public void whenRunWithPostJava5DebugArgumentsTestShouldFail() {
    JUnitCore core = new JUnitCore();
    Result result = core.run(PostJava5DebugArgumentsTest.class);
    assertEquals("Should run the test", 1, result.getRunCount());
    assertEquals("Test should not have failed", 0, result.getFailureCount());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) Test(org.junit.Test)

Aggregations

JUnitCore (org.junit.runner.JUnitCore)169 Result (org.junit.runner.Result)100 Test (org.junit.Test)88 Request (org.junit.runner.Request)32 PrintableResult.testResult (org.junit.experimental.results.PrintableResult.testResult)22 Failure (org.junit.runner.notification.Failure)21 Description (org.junit.runner.Description)16 RunListener (org.junit.runner.notification.RunListener)16 TestResult (junit.framework.TestResult)14 ArrayList (java.util.ArrayList)13 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