org.junit.runners.Suite#org.junit.runner.manipulation.NoTestsRemainException源码实例Demo

下面列出了org.junit.runners.Suite#org.junit.runner.manipulation.NoTestsRemainException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tinkerpop   文件: AbstractGremlinSuite.java
private void registerOptOuts(final Class<?> classWithOptOuts,
                             final Optional<GraphProvider.Descriptor> graphProviderDescriptor,
                             final TraversalEngine.Type traversalEngineType) throws InitializationError {
    // don't get why getAnnotationsByType() refuses to pick up OptOuts on the superclass. doing it manually and
    // only for the immediate superclass for now
    final List<Graph.OptOut> optOuts = getAllOptOuts(classWithOptOuts);

    if (!optOuts.isEmpty()) {
        // validate annotation - test class and reason must be set
        if (!optOuts.stream().allMatch(ignore -> ignore.test() != null && ignore.reason() != null && !ignore.reason().isEmpty()))
            throw new InitializationError("Check @IgnoreTest annotations - all must have a 'test' and 'reason' set");

        try {
            final Graph.OptOut[] oos = new Graph.OptOut[optOuts.size()];
            optOuts.toArray(oos);
            filter(new OptOutTestFilter(oos, graphProviderDescriptor, traversalEngineType));
        } catch (NoTestsRemainException ex) {
            throw new InitializationError(ex);
        }
    }
}
 
源代码2 项目: pitest   文件: AdaptedJUnitTestUnit.java
private void filterIfRequired(final ResultCollector rc, final Runner runner) {
  if (this.filter.isPresent()) {
    if (!(runner instanceof Filterable)) {
      LOG.warning("Not able to filter " + runner.getDescription()
          + ". Mutation may have prevented JUnit from constructing test");
      return;
    }
    final Filterable f = (Filterable) runner;
    try {
      f.filter(this.filter.get());
    } catch (final NoTestsRemainException e1) {
      rc.notifySkipped(this.getDescription());
      return;
    }
  }
}
 
源代码3 项目: mr-hashemi   文件: HashemTestRunner.java
public static void runInMain(Class<?> testClass, String[] args) throws InitializationError, NoTestsRemainException {
    JUnitCore core = new JUnitCore();
    core.addListener(new TextListener(System.out));
    HashemTestRunner suite = new HashemTestRunner(testClass);
    if (args.length > 0) {
        suite.filter(new NameFilter(args[0]));
    }
    Result r = core.run(suite);
    if (!r.wasSuccessful()) {
        System.exit(1);
    }
}
 
private void runEnabledTests(RunNotifier nested) {
    if (enabledTests.isEmpty()) {
        return;
    }

    Runner runner;
    try {
        runner = createExecutionRunner();
    } catch (Throwable t) {
        runner = new CannotExecuteRunner(getDisplayName(), target, t);
    }

    try {
        if (!disabledTests.isEmpty()) {
            ((Filterable) runner).filter(new Filter() {
                @Override
                public boolean shouldRun(Description description) {
                    return !disabledTests.contains(description);
                }

                @Override
                public String describe() {
                    return "disabled tests";
                }
            });
        }
    } catch (NoTestsRemainException e) {
        return;
    }

    runner.run(nested);
}
 
private void runEnabledTests(RunNotifier nested) {
    if (enabledTests.isEmpty()) {
        return;
    }

    Runner runner;
    try {
        runner = createExecutionRunner();
    } catch (Throwable t) {
        runner = new CannotExecuteRunner(getDisplayName(), target, t);
    }

    try {
        if (!disabledTests.isEmpty()) {
            ((Filterable) runner).filter(new Filter() {
                @Override
                public boolean shouldRun(Description description) {
                    return !disabledTests.contains(description);
                }

                @Override
                public String describe() {
                    return "disabled tests";
                }
            });
        }
    } catch (NoTestsRemainException e) {
        return;
    }

    runner.run(nested);
}
 
源代码6 项目: wycheproof   文件: WycheproofRunner.java
private void addFilter(Filter filter) {
  try {
    filter(filter);
  } catch (NoTestsRemainException ex) {
    System.out.println("No tests remain exception: " + ex);
  }
}
 
源代码7 项目: dsl-devkit   文件: FilterRegistry.java
/**
 * Initializes the test filter.
 *
 * @param parentRunner
 *          the {@link ParentRunner} to initialize, must not be {@code null}
 */
public static void initializeFilter(final ParentRunner<?> parentRunner) {
  try {
    parentRunner.filter(INSTANCE);
  } catch (NoTestsRemainException e) {
    // we ignore the case where no children are left
  }
}
 
源代码8 项目: Pushjet-Android   文件: AbstractMultiTestRunner.java
private void runEnabledTests(RunNotifier nested) {
    if (enabledTests.isEmpty()) {
        return;
    }

    Runner runner;
    try {
        runner = createExecutionRunner();
    } catch (Throwable t) {
        runner = new CannotExecuteRunner(getDisplayName(), target, t);
    }

    try {
        if (!disabledTests.isEmpty()) {
            ((Filterable) runner).filter(new Filter() {
                @Override
                public boolean shouldRun(Description description) {
                    return !disabledTests.contains(description);
                }

                @Override
                public String describe() {
                    return "disabled tests";
                }
            });
        }
    } catch (NoTestsRemainException e) {
        return;
    }

    runner.run(nested);
}
 
源代码9 项目: Pushjet-Android   文件: AbstractMultiTestRunner.java
private void runEnabledTests(RunNotifier nested) {
    if (enabledTests.isEmpty()) {
        return;
    }

    Runner runner;
    try {
        runner = createExecutionRunner();
    } catch (Throwable t) {
        runner = new CannotExecuteRunner(getDisplayName(), target, t);
    }

    try {
        if (!disabledTests.isEmpty()) {
            ((Filterable) runner).filter(new Filter() {
                @Override
                public boolean shouldRun(Description description) {
                    return !disabledTests.contains(description);
                }

                @Override
                public String describe() {
                    return "disabled tests";
                }
            });
        }
    } catch (NoTestsRemainException e) {
        return;
    }

    runner.run(nested);
}
 
源代码10 项目: android-test   文件: TestRequestBuilder.java
@Override
public Runner getRunner() {
  try {
    Runner runner = request.getRunner();
    filter.apply(runner);
    return runner;
  } catch (NoTestsRemainException e) {
    // don't treat filtering out all tests as an error
    return new BlankRunner();
  }
}
 
/**
 * Constructs a new {@code SpringJUnit4ClassRunner} and initializes a
 * {@link org.springframework.test.context.TestContextManager} to provide Spring testing functionality to
 * standard JUnit tests.
 *
 * @param clazz the test class to be run
 * @see #createTestContextManager(Class)
 */
public LdapConditionallyFilteredTestRunner(Class<?> clazz) throws InitializationError {
    super(clazz);

    String noadtest = System.getProperty("adtest");
    if (noadtest != null) {
        try {
            filter(Categories.CategoryFilter.exclude(NoAdTest.class));
        } catch (NoTestsRemainException e) {
            // Nothing to do here.
        }
    }
}
 
源代码12 项目: bazel   文件: JUnit4Runner.java
private static Request applyFilter(Request request, Filter filter)
    throws NoTestsRemainException {
  Runner runner = request.getRunner();
  new SuiteTrimmingFilter(filter).apply(runner);
  return Request.runner(runner);
}
 
源代码13 项目: bazel   文件: Filters.java
/**
 * Returns a Request that only contains those tests that should run when
 * a filter is applied, filtering out all empty suites.<p>
 *
 * Note that if the request passed into this method caches its runner,
 * that runner will be modified to use the given filter. To be safe,
 * do not use the passed-in request after calling this method.
 *
 * @param request Request to filter
 * @param filter Filter to apply
 * @return request
 * @throws NoTestsRemainException if the applying the filter removes all tests
 */
public static Request apply(Request request, Filter filter) throws NoTestsRemainException {
  filter = new SuiteTrimmingFilter(filter);
  Runner runner = request.getRunner();
  filter.apply(runner);

  return Request.runner(runner);
}