org.junit.runner.Request.getRunner()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.junit.runner.Request.getRunner方法的一些代码示例,展示了Request.getRunner的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getRunner方法的具体详情如下:
包路径:org.junit.runner.Request
类名称:Request
方法名:getRunner

Request.getRunner介绍

[英]Returns a Runner for this Request
[中]返回此请求的运行程序

代码示例

代码示例来源:origin: junit-team/junit4

public JUnit4TestAdapter(final Class<?> newTestClass, JUnit4TestAdapterCache cache) {
  fCache = cache;
  fNewTestClass = newTestClass;
  fRunner = Request.classWithoutSuiteMethod(newTestClass).getRunner();
}

代码示例来源:origin: junit-team/junit4

/**
 * Run all the tests contained in <code>request</code>.
 *
 * @param request the request describing tests
 * @return a {@link Result} describing the details of the test run and the failed tests.
 */
public Result run(Request request) {
  return run(request.getRunner());
}

代码示例来源:origin: google/j2objc

/**
 * Run all the tests contained in <code>request</code>.
 *
 * @param request the request describing tests
 * @return a {@link Result} describing the details of the test run and the failed tests.
 */
public Result run(Request request) {
  return run(request.getRunner());
}

代码示例来源:origin: google/j2objc

public JUnit4TestAdapter(final Class<?> newTestClass, JUnit4TestAdapterCache cache) {
  fCache = cache;
  fNewTestClass = newTestClass;
  fRunner = Request.classWithoutSuiteMethod(newTestClass).getRunner();
}

代码示例来源:origin: junit-team/junit4

@Override
  protected Runner createRunner() {
    Runner runner = request.getRunner();
    try {
      ordering.apply(runner);
    } catch (InvalidOrderingException e) {
      return new ErrorReportingRunner(ordering.getClass(), e);
    }
    return runner;
  }
}

代码示例来源:origin: junit-team/junit4

private List<Description> findLeaves(Request request) {
  List<Description> results = new ArrayList<Description>();
  findLeaves(null, request.getRunner().getDescription(), results);
  return results;
}

代码示例来源:origin: junit-team/junit4

@Override
  public Runner getRunner() {
    try {
      Runner runner = request.getRunner();
      fFilter.apply(runner);
      return runner;
    } catch (NoTestsRemainException e) {
      return new ErrorReportingRunner(Filter.class, new Exception(String
          .format("No tests found matching %s from %s", fFilter
              .describe(), request.toString())));
    }
  }
}

代码示例来源:origin: google/j2objc

private List<Description> findLeaves(Request request) {
  List<Description> results = new ArrayList<Description>();
  findLeaves(null, request.getRunner().getDescription(), results);
  return results;
}

代码示例来源:origin: google/j2objc

@Override
  public Runner getRunner() {
    try {
      Runner runner = fRequest.getRunner();
      fFilter.apply(runner);
      return runner;
    } catch (NoTestsRemainException e) {
      return new ErrorReportingRunner(Filter.class, new Exception(String
          .format("No tests found matching %s from %s", fFilter
              .describe(), fRequest.toString())));
    }
  }
}

代码示例来源:origin: junit-team/junit4

@Override
  public Runner getRunner() {
    Runner runner = request.getRunner();
    new Sorter(comparator).apply(runner);
    return runner;
  }
}

代码示例来源:origin: google/j2objc

@Override
  public Runner getRunner() {
    Runner runner = fRequest.getRunner();
    new Sorter(fComparator).apply(runner);
    return runner;
  }
}

代码示例来源:origin: junit-team/junit4

/**
 * Creates a {@link Filter}.
 *
 * A filter specification is of the form "package.of.FilterFactory=args-to-filter-factory" or
 * "package.of.FilterFactory".
 *
 * @param request the request that will be filtered
 * @param filterSpec the filter specification
 * @throws org.junit.runner.FilterFactory.FilterNotCreatedException
 */
public static Filter createFilterFromFilterSpec(Request request, String filterSpec)
    throws FilterFactory.FilterNotCreatedException {
  Description topLevelDescription = request.getRunner().getDescription();
  String[] tuple;
  if (filterSpec.contains("=")) {
    tuple = filterSpec.split("=", 2);
  } else {
    tuple = new String[]{ filterSpec, "" };
  }
  return createFilter(tuple[0], new FilterFactoryParams(topLevelDescription, tuple[1]));
}

代码示例来源:origin: apache/geode

public static Failure runTestWithExpectedFailure(final Class<?> test) {
 JUnitCore junitCore = new JUnitCore();
 Result result = junitCore.run(Request.aClass(test).getRunner());
 List<Failure> failures = result.getFailures();
 assertThat(failures).hasSize(1);
 return failures.get(0);
}

代码示例来源:origin: junit-team/junit4

private Runner buildRunner(Description each) {
  if (each.toString().equals("TestSuite with 0 tests")) {
    return Suite.emptySuite();
  }
  if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) {
    // This is cheating, because it runs the whole class
    // to get the warning for this method, but we can't do better,
    // because JUnit 3.8's
    // thrown away which method the warning is for.
    return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each)));
  }
  Class<?> type = each.getTestClass();
  if (type == null) {
    throw new RuntimeException("Can't build a runner from description [" + each + "]");
  }
  String methodName = each.getMethodName();
  if (methodName == null) {
    return Request.aClass(type).getRunner();
  }
  return Request.method(type, methodName).getRunner();
}

代码示例来源:origin: apache/geode

public static Result runTestWithValidation(final Class<?> test) {
 JUnitCore junitCore = new JUnitCore();
 Result result = junitCore.run(Request.aClass(test).getRunner());
 List<Failure> failures = result.getFailures();
 if (!failures.isEmpty()) {
  Failure firstFailure = failures.get(0);
  throw new AssertionError(firstFailure.getException());
 }
 assertThat(result.wasSuccessful()).isTrue();
 return result;
}

代码示例来源:origin: junit-team/junit4

/**
 * Run all the tests contained in <code>request</code>.
 *
 * This variant should be used if {@code core} has attached listeners that this
 * run should notify.
 *
 * @param request the request describing tests
 * @param core a JUnitCore to delegate to.
 * @return a {@link Result} describing the details of the test run and the failed tests.
 */
public Result run(Request request, JUnitCore core) {
  core.addListener(history.listener());
  return core.run(sortRequest(request).getRunner());
}

代码示例来源:origin: google/j2objc

/**
 * Run all the tests contained in <code>request</code>.
 *
 * This variant should be used if {@code core} has attached listeners that this
 * run should notify.
 *
 * @param request the request describing tests
 * @param core a JUnitCore to delegate to.
 * @return a {@link Result} describing the details of the test run and the failed tests.
 */
public Result run(Request request, JUnitCore core) {
  core.addListener(fHistory.listener());
  return core.run(sortRequest(request).getRunner());
}

代码示例来源:origin: apache/geode

public static List<Failure> runTestWithExpectedFailures(final Class<?> test) {
  JUnitCore junitCore = new JUnitCore();
  Result result = junitCore.run(Request.aClass(test).getRunner());

  List<Failure> failures = result.getFailures();
  assertThat(failures).isNotEmpty();

  return failures;
 }
}

代码示例来源:origin: apache/geode

@Test
public void testWorkingCategoryAndParameterized() {
 Request request = Request.aClass(WorkingCategoryClass.class);
 ExposedParameterized runner = (ExposedParameterized) request.getRunner();
 request =
   request.filterWith(new CategoryFilter((ExposedGetAnnotations) runner.getChildren().get(0)));
 Result result = new JUnitCore().run(request);
 assertEquals(2, result.getRunCount());
}

代码示例来源:origin: apache/geode

@Test
public void testBrokenCategoryAndParameterized() {
 Request request = Request.aClass(BrokenCategoryClass.class);
 ExposedParameterized runner = (ExposedParameterized) request.getRunner();
 request = request.filterWith(new CategoryFilter(
   (ExposedBlockJUnit4ClassRunnerWithParameters) runner.getChildren().get(0)));
 Result result = new JUnitCore().run(request);
 assertEquals(
   "Yeah!! This might actually mean we've upgraded to JUnit 4.13. Hurry up already and delete this hack.",
   1, result.getRunCount());
}

相关文章