org.junit.runner.manipulation.Filterable Java Examples

The following examples show how to use org.junit.runner.manipulation.Filterable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdaptedJUnitTestUnit.java    From pitest with Apache License 2.0 6 votes vote down vote up
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;
    }
  }
}
 
Example #2
Source File: JUnitCustomRunnerTestUnitFinder.java    From pitest with Apache License 2.0 6 votes vote down vote up
@Override
public List<TestUnit> findTestUnits(final Class<?> clazz) {

  final Runner runner = AdaptedJUnitTestUnit.createRunner(clazz);

  if (isExcluded(runner) || isNotARunnableTest(runner, clazz.getName()) || !isIncluded(clazz)) {
    return Collections.emptyList();
  }

  if (Filterable.class.isAssignableFrom(runner.getClass())
      && !shouldTreatAsOneUnit(clazz, runner)) {
    final List<TestUnit> filteredUnits = splitIntoFilteredUnits(runner.getDescription());
    return filterUnitsByMethod(filteredUnits);
  } else {
    return Collections.<TestUnit> singletonList(new AdaptedJUnitTestUnit(
        clazz, Optional.<Filter> empty()));
  }
}
 
Example #3
Source File: AbstractMultiTestRunner.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #4
Source File: AbstractMultiTestRunner.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #5
Source File: AbstractMultiTestRunner.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #6
Source File: AbstractMultiTestRunner.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}