Java 类org.junit.runner.manipulation.NoTestsRemainException 实例源码

项目:LiteGraph    文件:AbstractGremlinSuite.java   
private void registerOptOuts(final Class<? extends Graph> graphClass,
                             final Optional<GraphProvider.Descriptor> graphProviderDescriptor,
                             final TraversalEngine.Type traversalEngineType) throws InitializationError {
    final Graph.OptOut[] optOuts = graphClass.getAnnotationsByType(Graph.OptOut.class);

    if (optOuts != null && optOuts.length > 0) {
        // validate annotation - test class and reason must be set
        if (!Arrays.stream(optOuts).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 {
            filter(new OptOutTestFilter(optOuts, graphProviderDescriptor, traversalEngineType));
        } catch (NoTestsRemainException ex) {
            throw new InitializationError(ex);
        }
    }
}
项目:tinkerpop    文件:AbstractGremlinSuite.java   
private void registerOptOuts(final Class<? extends Graph> graphClass,
                             final Optional<GraphProvider.Descriptor> graphProviderDescriptor,
                             final TraversalEngine.Type traversalEngineType) throws InitializationError {
    final Graph.OptOut[] optOuts = graphClass.getAnnotationsByType(Graph.OptOut.class);

    if (optOuts != null && optOuts.length > 0) {
        // validate annotation - test class and reason must be set
        if (!Arrays.stream(optOuts).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 {
            filter(new OptOutTestFilter(optOuts, graphProviderDescriptor, traversalEngineType));
        } catch (NoTestsRemainException ex) {
            throw new InitializationError(ex);
        }
    }
}
项目:ef-orm    文件:JefJUnit4DatabaseTestRunner.java   
@Override
public void filter(final Filter raw) throws NoTestsRemainException {
    super.filter(new Filter() {
        @Override
        public boolean shouldRun(Description description) {
            String testDisplay = StringUtils.substringBefore(description.getDisplayName(), " ");
            if (testDisplay != description.getDisplayName()) {
                description = Description.createTestDescription(description.getTestClass(), testDisplay);
            }
            return raw.shouldRun(description);
        }

        @Override
        public String describe() {
            return raw.describe();
        }
    });
}
项目:pitest    文件:AdaptedJUnitTestUnit.java   
private void filterIfRequired(final ResultCollector rc, final Runner runner) {
  if (this.filter.hasSome()) {
    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.value());
    } catch (final NoTestsRemainException e1) {
      rc.notifySkipped(this.getDescription());
      return;
    }
  }
}
项目:Reer    文件: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);
}
项目:rtest    文件:FilterData.java   
public Filter getFilter() {
    return new Filter() {
        @Override
        public boolean shouldRun(Description description) {
            return Boolean.TRUE.equals(context.get(description));
        }

        @Override
        public String describe() {
            return "RTest Filter";
        }

        @Override
        public void apply(Object child) throws NoTestsRemainException {
            if(child instanceof Filterable) {
                Filterable filterableChild = (Filterable) child;
                filterableChild.filter(this);
            }
        }
    };
    //return Filter.matchMethodDescription(desiredDescription);
       /*return new Filter() {
           @Override
           public boolean shouldRun(Description description) {
               return (toRun.contains(description));

           }

           @Override
           public String describe() {
               return "RTest methods filter";
           }
       };*/

}
项目:wycheproof    文件:WycheproofRunner.java   
private void addFilter(Filter filter) {
  try {
    filter(filter);
  } catch (NoTestsRemainException ex) {
    System.out.println("No tests remain exception: " + ex);
  }
}
项目: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
  }
}
项目:intellij-ce-playground    文件:IdeaSuite48.java   
private void filterByCategory(Class category) throws InitializationError {
  if (category != null) {
    try {
      final Categories.CategoryFilter categoryFilter = Categories.CategoryFilter.include(category);
      filter(categoryFilter);
    } catch (NoTestsRemainException e) {
      throw new RuntimeException(e);
    }
  }
}
项目:aaf-junit    文件:ConcurrentDependsOnClasspathSuite.java   
private void applyMethodFilter() throws InitializationError {
    for (Runner r : getChildren()) {
        try {
            if (r instanceof ParentRunner<?>) {
                ((ParentRunner<?>) r).filter(methodFilter);
            }
        } catch (NoTestsRemainException e) {
            throw new InitializationError(e);
        }
    }
}
项目:powermock    文件:PowerMockJUnit4LegacyRunnerDelegateImpl.java   
public PowerMockJUnit4LegacyRunnerDelegateImpl(Class<?> klass, String[] methodsToRun,
        PowerMockTestListener[] listeners) throws InitializationError, NoTestsRemainException {
    super(klass, new PowerMockJUnit4LegacyTestClassMethodsRunner(klass,
            listeners == null ? new PowerMockTestListener[0] : listeners));
    filter(new PowerMockJUnit4LegacyFilter(methodsToRun));

    testCount = methodsToRun.length;
}
项目:android-groovy-dagger-espresso-demo    文件:SpockTestRequestBuilder.java   
@Override
public Runner getRunner() {
    try {
        Runner runner = mRequest.getRunner();
        mFilter.apply(runner);
        return runner;
    } catch (NoTestsRemainException e) {
        // don't treat filtering out all tests as an error
        return new BlankRunner();
    }
}
项目: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);
}
项目: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);
}
项目:jmeter-spock-sampler    文件:SpockSpecRunner.java   
public static Result execute(final Class<?> classOfspecToRun, final String methodName) throws InitializationError, NoTestsRemainException {

        final Result testResult = new Result();

        Sputnik spockRunner = new Sputnik(classOfspecToRun);
        if(methodName != null && !methodName.equals("")) {
            SpockSpecificationFilter filter = new SpockSpecificationFilter(spockRunner, methodName);
            spockRunner.filter(filter);
        }

        runTest(spockRunner, testResult);

        return testResult;
    }
项目:sosiefier    文件:Categories.java   
public Categories(Class<?> klass, RunnerBuilder builder) throws InitializationError {
    super(klass, builder);
    try {
        Set<Class<?>> included= getIncludedCategory(klass);
        Set<Class<?>> excluded= getExcludedCategory(klass);
        boolean isAnyIncluded= isAnyIncluded(klass);
        boolean isAnyExcluded= isAnyExcluded(klass);

        filter(CategoryFilter.categoryFilter(isAnyIncluded, included, isAnyExcluded, excluded));
    } catch (NoTestsRemainException e) {
        throw new InitializationError(e);
    }
    assertNoCategorizedDescendentsOfUncategorizeableParents(getDescription());
}
项目:sosiefier    文件:FilterRequest.java   
@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())));
    }
}
项目:sosiefier    文件:CategoryTest.java   
@Test
public void categoryFilterLeavesOnlyMatchingMethods()
        throws InitializationError, NoTestsRemainException {
    CategoryFilter filter = CategoryFilter.include(SlowTests.class);
    BlockJUnit4ClassRunner runner = new BlockJUnit4ClassRunner(A.class);
    filter.apply(runner);
    assertEquals(1, runner.testCount());
}
项目:sosiefier    文件:CategoryTest.java   
@Test
public void categoryFilterRejectsIncompatibleCategory()
        throws InitializationError, NoTestsRemainException {
    CategoryFilter filter = CategoryFilter.include(SlowTests.class);
    BlockJUnit4ClassRunner runner = new BlockJUnit4ClassRunner(
            OneFastOneSlow.class);
    filter.apply(runner);
    assertEquals(1, runner.testCount());
}
项目:sosiefier    文件:ParentRunnerFilteringTest.java   
@Test
public void testSuiteFiltering() throws Exception {
    Runner runner = Request.aClass(ExampleSuite.class).getRunner();
    Filter filter = notThisMethodName("test1");
    try {
        filter.apply(runner);
    } catch (NoTestsRemainException e) {
        return;
    }
    fail("Expected 'NoTestsRemainException' due to complete filtering");
}
项目:sosiefier    文件:ParentRunnerFilteringTest.java   
@Test
public void testSuiteFilteringWithUnmodifyableChildList() throws Exception {
    Runner runner = Request.aClass(ExampleSuiteWithUnmodifyableChildList.class)
            .getRunner();
    Filter filter = notThisMethodName("test1");
    try {
        filter.apply(runner);
    } catch (NoTestsRemainException e) {
        return;
    }
    fail("Expected 'NoTestsRemainException' due to complete filtering");
}
项目:sosiefier    文件:SingleMethodTest.java   
@Test(expected = NoTestsRemainException.class)
public void filteringAwayEverythingThrowsException() throws NoTestsRemainException {
    Filterable runner = (Filterable) Request.aClass(OneTimeSetup.class).getRunner();
    runner.filter(new Filter() {
        @Override
        public boolean shouldRun(Description description) {
            return false;
        }

        @Override
        public String describe() {
            return null;
        }
    });
}
项目:usb4java-javax    文件:TCKRunner.java   
/**
 * Constructor.
 * 
 * @param testClass
 *            The test class.
 * @throws NoTestsRemainException
 *             When no tests are to be run in this test class.
 */
public TCKRunner(final Class<?> testClass) throws NoTestsRemainException
{
    super(testClass);
    filter(new Filter()
    {
        @Override
        public boolean shouldRun(Description description)
        {
            try
            {
                UsbAssume.assumeTckTestsEnabled();
                return true;
            }
            catch (AssumptionViolatedException e)
            {
                return false;
            }
        }

        @Override
        public String describe()
        {
            return "TCK tests only when enabled";
        }
    });
}
项目:lcm    文件:Categories.java   
public Categories(Class<?> klass, RunnerBuilder builder)
        throws InitializationError {
    super(klass, builder);
    try {
        filter(new CategoryFilter(getIncludedCategory(klass),
                getExcludedCategory(klass)));
    } catch (NoTestsRemainException e) {
        throw new InitializationError(e);
    }
    assertNoCategorizedDescendentsOfUncategorizeableParents(getDescription());
}
项目:lcm    文件:FilterRequest.java   
@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())));
    }
}
项目:junit-single-method-runner    文件:SingleMethodRunner.java   
public SingleMethodRunner(Class<?> klass) throws InitializationError {
super(klass);

try {
    this.children = computeChildren();
} catch (RuntimeException | ClassNotFoundException
    | NoTestsRemainException e) {
    throw new InitializationError(e);
}

   }
项目:junit-single-method-runner    文件:SingleMethodRunner.java   
private List<Runner> computeChildren() throws InitializationError,
    ClassNotFoundException, NoTestsRemainException {

String testMethodPattern = System
    .getProperty(TEST_METHOD_PROPERTY_NAME);

if (testMethodPattern == null) {
    return Collections.emptyList();
}

return Collections
    .singletonList(junitRunnerFor(new TestMethodReference(
        testMethodPattern)));
   }
项目:junit    文件:Categories.java   
public Categories(Class<?> klass, RunnerBuilder builder)
        throws InitializationError {
    super(klass, builder);
    try {
        filter(new CategoryFilter(getIncludedCategory(klass),
                getExcludedCategory(klass)));
    } catch (NoTestsRemainException e) {
        throw new InitializationError(e);
    }
    assertNoCategorizedDescendentsOfUncategorizeableParents(getDescription());
}
项目:junit    文件:FilterRequest.java   
@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())));
    }
}
项目:junit    文件:CategoryTest.java   
@Test
public void categoryFilterLeavesOnlyMatchingMethods()
        throws InitializationError, NoTestsRemainException {
    CategoryFilter filter = CategoryFilter.include(SlowTests.class);
    BlockJUnit4ClassRunner runner = new BlockJUnit4ClassRunner(A.class);
    filter.apply(runner);
    assertEquals(1, runner.testCount());
}
项目:junit    文件:CategoryTest.java   
@Test
public void categoryFilterRejectsIncompatibleCategory()
        throws InitializationError, NoTestsRemainException {
    CategoryFilter filter = CategoryFilter.include(SlowTests.class);
    BlockJUnit4ClassRunner runner = new BlockJUnit4ClassRunner(
            OneFastOneSlow.class);
    filter.apply(runner);
    assertEquals(1, runner.testCount());
}
项目:junit    文件:ParentRunnerFilteringTest.java   
@Test
public void testSuiteFiltering() throws Exception {
    Runner runner = Request.aClass(ExampleSuite.class).getRunner();
    Filter filter = notThisMethodName("test1");
    try {
        filter.apply(runner);
    } catch (NoTestsRemainException e) {
        return;
    }
    fail("Expected 'NoTestsRemainException' due to complete filtering");
}
项目:junit    文件:ParentRunnerFilteringTest.java   
@Test
public void testSuiteFilteringWithUnmodifyableChildList() throws Exception {
    Runner runner = Request.aClass(ExampleSuiteWithUnmodifyableChildList.class)
            .getRunner();
    Filter filter = notThisMethodName("test1");
    try {
        filter.apply(runner);
    } catch (NoTestsRemainException e) {
        return;
    }
    fail("Expected 'NoTestsRemainException' due to complete filtering");
}
项目:junit    文件:SingleMethodTest.java   
@Test(expected = NoTestsRemainException.class)
public void filteringAwayEverythingThrowsException() throws NoTestsRemainException {
    Filterable runner = (Filterable) Request.aClass(OneTimeSetup.class).getRunner();
    runner.filter(new Filter() {
        @Override
        public boolean shouldRun(Description description) {
            return false;
        }

        @Override
        public String describe() {
            return null;
        }
    });
}
项目:spring-ldap    文件:LdapConditionallyFilteredTestRunner.java   
/**
 * 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.
        }
    }
}
项目:org.openntf.domino    文件:Categories.java   
public Categories(Class<?> klass, RunnerBuilder builder)
        throws InitializationError {
    super(klass, builder);
    try {
        filter(new CategoryFilter(getIncludedCategory(klass),
                getExcludedCategory(klass)));
    } catch (NoTestsRemainException e) {
        throw new InitializationError(e);
    }
    assertNoCategorizedDescendentsOfUncategorizeableParents(getDescription());
}
项目:org.openntf.domino    文件:FilterRequest.java   
@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())));
    }
}
项目:health-and-care-developer-network    文件:CategoryTest.java   
@Test
public void categoryFilterLeavesOnlyMatchingMethods()
        throws InitializationError, NoTestsRemainException {
    CategoryFilter filter = CategoryFilter.include(SlowTests.class);
    BlockJUnit4ClassRunner runner = new BlockJUnit4ClassRunner(A.class);
    filter.apply(runner);
    assertEquals(1, runner.testCount());
}
项目:health-and-care-developer-network    文件:CategoryTest.java   
@Test
public void categoryFilterRejectsIncompatibleCategory()
        throws InitializationError, NoTestsRemainException {
    CategoryFilter filter = CategoryFilter.include(SlowTests.class);
    BlockJUnit4ClassRunner runner = new BlockJUnit4ClassRunner(
            OneFastOneSlow.class);
    filter.apply(runner);
    assertEquals(1, runner.testCount());
}
项目:health-and-care-developer-network    文件:ParentRunnerFilteringTest.java   
@Test
public void testSuiteFiltering() throws Exception {
    Runner runner = Request.aClass(ExampleSuite.class).getRunner();
    Filter filter = notThisMethodName("test1");
    try {
        filter.apply(runner);
    } catch (NoTestsRemainException e) {
        return;
    }
    fail("Expected 'NoTestsRemainException' due to complete filtering");
}