Java 类org.junit.runner.Computer 实例源码

项目:sunshine    文件:Junit4Engine.java   
@Override
public void run() throws EngineException {
    try {
        Result result = jUnitCore.run(new Computer(), suite.tests());
        System.out.println(
                String.format(
                        "Total tests run: %s, Failures: %s, Skips: %s",
                        result.getRunCount(),
                        result.getFailureCount(),
                        result.getIgnoreCount()
                )
        );
        System.exit(result.wasSuccessful() ? 0 : -1);
    } catch (SuiteException e) {
        throw new EngineException("Some problem occurs in the Junit4 engine", e);
    }
}
项目:junit-composite-runner    文件:CompositeRunnerTest.java   
@Test
public void testSystem() throws Throwable {
    Computer computer = new Computer();
    JUnitCore jUnitCore = new JUnitCore();

    ByteArrayOutputStream capture = new ByteArrayOutputStream();
    final PrintStream printStream = new PrintStream(capture);
    TextListener listener = new TextListener(printStream);
    jUnitCore.addListener(listener);

    PrintStream systemOut = System.out;
    System.setOut(printStream);
    try {
        jUnitCore.run(computer, ExampleTest.class);
    } finally {
        System.setOut(systemOut);
    }

    String output = capture.toString("UTF-8");
    output = normalizeOutput(output);

    String expectedOutput = getResource("/CompositeTest.testSystem.expected.txt");
    Assert.assertEquals(expectedOutput, output);
}
项目:Gepard    文件:TestClassExecutionThread.java   
private void execClass(final TestClassExecutionData o) {
    classData = o;
    CLASS_DATA_IN_CONTEXT.set(o);
    try {
        HtmlRunReporter reporter = o.getHtmlRunReporter();
        reporter.hiddenBeforeTestClassExecution();
        core.addListener(reporter);

        Result result = core.run(Computer.serial(), o.getTestClass());
        for (Failure failure : result.getFailures()) {
            LOGGER.debug(failure.toString());
        }
        classData.setCountOfRuns(result.getRunCount());
        core.removeListener(reporter);
        reporter.hiddenAfterTestClassExecution();
    } catch (Throwable e) {
        //this is gas
        LOGGER.debug("Thread: got EX during JUnitCore execution.", e);
    }
    CLASS_DATA_IN_CONTEXT.set(null);
    classData = null;
}
项目:sunshine    文件:Junit4Kernel.java   
/**
 * Returns status of JUnite tests execution.
 *
 * @return the status
 * @throws KernelException if any error occurs during JUnit tests execution.
 */
@Override
public Status status() throws KernelException {
    try {
        return new JunitStatus(this.junit.run(new Computer(), this.suiteForRun.tests()));
    } catch (SuiteException e) {
        throw new KernelException("Some problem occurs in the Junit4Kernel", e);
    }
}
项目:robolayout    文件:XCTestRunner.java   
@Override
public void didBecomeActive(UIApplication application) {
    super.didBecomeActive(application);

    NSException.registerDefaultJavaUncaughtExceptionHandler();

    Computer computer = new Computer();

    JUnitCore jUnitCore = new JUnitCore();
    jUnitCore.addListener(new TextListener(System.out));
    jUnitCore.run(computer, getTestClasses());
}
项目:android-groovy-dagger-espresso-demo    文件:SpockTestRequestBuilder.java   
/**
 * Builds the {@link android.support.test.internal.runner.TestRequest} based on current contents of added classes and methods.
 * <p/>
 * If no classes have been explicitly added, will scan the classpath for all tests.
 */
public TestRequest build(Instrumentation instr, Bundle bundle) {
    if (mTestLoader.isEmpty()) {
        // no class restrictions have been specified. Load all classes
        loadClassesFromClassPath();
    }

    Request request = classes(
            new AndroidRunnerParams(instr, bundle, mSkipExecution, mPerTestTimeout),
            new Computer(),
            mTestLoader.getLoadedClasses().toArray(new Class[0]));
    return new TestRequest(mTestLoader.getLoadFailures(),
            new LenientFilterRequest(request, mFilter));
}
项目:sosiefier    文件:MaxStarterTest.java   
@Test
public void sortTestsInMultipleClasses() {
    Request request = Request.classes(Computer.serial(), TwoTests.class,
            TwoTests.class);
    fMax.run(request);
    List<Description> tests = fMax.sortedLeavesForTest(request);
    Description dontSucceed = Description.createTestDescription(
            TwoTests.class, "dontSucceed");
    assertEquals(dontSucceed, tests.get(0));
    assertEquals(dontSucceed, tests.get(1));
}
项目:WikiIndexer    文件:Runner.java   
/**
 * Method to execute all tests
 *
 * @param filename: Filename for the properties file
 */
private static void runTests(String filename) {
    System.setProperty("PROPSFILENAME", filename);
    JUnitCore core = new JUnitCore();
    core.run(new Computer(), AllTests.class);

}
项目:WikiIndexer    文件:SingleRunner.java   
/**
 * Method to execute all tests
 * @param filename: Filename for the properties file
 */
private static void runTests(String filename) {
    System.setProperty("PROPSFILENAME", filename);
    JUnitCore core = new JUnitCore();
    core.run(new Computer(), AllTests.class);

}
项目:opennmszh    文件:GroovyRunnerTest.java   
private Result runJunitTestWithComputer(Computer computer, Class<?> clazz) {
    Result result = JUnitCore.runClasses(computer, clazz);

    List<Failure> failures = result.getFailures();
    for(Failure failure : failures) {
        System.out.println(failure.getMessage());
    }
    return result;
}
项目:buck    文件:JUnitRunner.java   
@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);
  }
}
项目:junit    文件:MaxStarterTest.java   
@Test
public void sortTestsInMultipleClasses() {
    Request request = Request.classes(Computer.serial(), TwoTests.class,
            TwoTests.class);
    fMax.run(request);
    List<Description> tests = fMax.sortedLeavesForTest(request);
    Description dontSucceed = Description.createTestDescription(
            TwoTests.class, "dontSucceed");
    assertEquals(dontSucceed, tests.get(0));
    assertEquals(dontSucceed, tests.get(1));
}
项目:health-and-care-developer-network    文件:MaxStarterTest.java   
@Test
public void sortTestsInMultipleClasses() {
    Request request = Request.classes(Computer.serial(), TwoTests.class,
            TwoTests.class);
    fMax.run(request);
    List<Description> tests = fMax.sortedLeavesForTest(request);
    Description dontSucceed = Description.createTestDescription(
            TwoTests.class, "dontSucceed");
    assertEquals(dontSucceed, tests.get(0));
    assertEquals(dontSucceed, tests.get(1));
}
项目:OpenNMS    文件:GroovyRunnerTest.java   
private Result runJunitTestWithComputer(Computer computer, Class<?> clazz) {
    Result result = JUnitCore.runClasses(computer, clazz);

    List<Failure> failures = result.getFailures();
    for(Failure failure : failures) {
        System.out.println(failure.getMessage());
    }
    return result;
}
项目:wikipedia_indexer    文件:Runner.java   
/**
 * Method to execute all tests
 * @param filename: Filename for the properties file
 */
private static void runTests(String filename) {
    System.setProperty("PROPSFILENAME", filename);
    JUnitCore core = new JUnitCore();
    core.run(new Computer(), AllTests.class);

}
项目:wikipedia_indexer    文件:SingleRunner.java   
/**
 * Method to execute all tests
 * @param filename: Filename for the properties file
 */
private static void runTests(String filename) {
    System.setProperty("PROPSFILENAME", filename);
    JUnitCore core = new JUnitCore();
    core.run(new Computer(), AllTests.class);

}
项目:marathonv5    文件:ParallelComputer.java   
public static Computer classes() {
    return new ParallelComputer(true, false);
}
项目:marathonv5    文件:ParallelComputer.java   
public static Computer methods() {
    return new ParallelComputer(false, true);
}
项目:marathonv5    文件:MarathonTestRunner.java   
static Computer defaultComputer() {
    return new Computer();
}
项目:sosiefier    文件:ParallelComputer.java   
public static Computer classes() {
    return new ParallelComputer(true, false);
}
项目:sosiefier    文件:ParallelComputer.java   
public static Computer methods() {
    return new ParallelComputer(false, true);
}
项目:lcm    文件:ParallelComputer.java   
public static Computer classes() {
    return new ParallelComputer(true, false);
}
项目:lcm    文件:ParallelComputer.java   
public static Computer methods() {
    return new ParallelComputer(false, true);
}
项目:junit    文件:ParallelComputer.java   
public static Computer classes() {
    return new ParallelComputer(true, false);
}
项目:junit    文件:ParallelComputer.java   
public static Computer methods() {
    return new ParallelComputer(false, true);
}
项目:org.openntf.domino    文件:ParallelComputer.java   
public static Computer classes() {
    return new ParallelComputer(true, false);
}
项目:org.openntf.domino    文件:ParallelComputer.java   
public static Computer methods() {
    return new ParallelComputer(false, true);
}
项目:opennmszh    文件:GroovyRunnerTest.java   
@Test
public void testCustomJUnitRunnerWithComputer() throws CompilationFailedException, IOException {
    String filename = "src/test/resources/groovy/GroovyRunnerTest.groovy";

    Computer computer = new SeleniumComputer("http://www.papajohns.co.uk");

    Result result = runJunitTestWithComputer(computer, getGroovyClass(filename));

    assertEquals(0, result.getFailureCount());
}
项目:OpenNMS    文件:GroovyRunnerTest.java   
@Test
public void testCustomJUnitRunnerWithComputer() throws CompilationFailedException, IOException {
    String filename = "src/test/resources/groovy/GroovyRunnerTest.groovy";

    Computer computer = new SeleniumComputer("http://www.papajohns.co.uk");

    Result result = runJunitTestWithComputer(computer, getGroovyClass(filename));

    assertEquals(0, result.getFailureCount());
}
项目:marathonv5    文件:MarathonTestRunner.java   
/**
 * Run the tests contained in <code>classes</code>. Write feedback while the
 * tests are running and write stack traces for all failed tests after all
 * tests complete. This is similar to {@link #main(String[])}, but intended
 * to be used programmatically.
 *
 * @param computer
 *            Helps construct Runners from classes
 * @param classes
 *            Classes in which to find tests
 * @return a {@link Result} describing the details of the test run and the
 *         failed tests.
 */
public static Result runClasses(Computer computer, Class<?>... classes) {
    return new MarathonTestRunner().run(computer, classes);
}
项目:marathonv5    文件:MarathonTestRunner.java   
/**
 * Run all the tests in <code>classes</code>.
 *
 * @param computer
 *            Helps construct Runners from classes
 * @param classes
 *            the classes containing tests
 * @return a {@link Result} describing the details of the test run and the
 *         failed tests.
 */
public Result run(Computer computer, Class<?>... classes) {
    return run(Request.classes(computer, classes));
}