@Override
 public void filter(Filter filter) throws NoTestsRemainException {
   filteredTests = allTests.filter(p -> filter.shouldRun(p._3()));
   if (filteredTests.isEmpty()) {
     throw new NoTestsRemainException();
   }
 }
 public void filter(Filter filter) throws NoTestsRemainException {
   for (Iterator<JUnit4TestMethod> iter = m_testMethods.iterator(); iter.hasNext(); ) {
     JUnit4TestMethod method = iter.next();
     if (!filter.shouldRun(methodDescription(method.getTestMethod()))) {
       iter.remove();
     }
   }
   if (m_testMethods.isEmpty()) {
     throw new NoTestsRemainException();
   }
 }
  /** {@inheritDoc} */
  @Override
  public void filter(final Filter filter) throws NoTestsRemainException {
    computeTestMethods();

    for (final ListIterator<FrameworkMethod> iter = testMethods_.listIterator(); iter.hasNext(); ) {
      final FrameworkMethod method = iter.next();
      // compute 2 descriptions to verify if it is the intended test:
      // - one "normal", this is what Eclipse's filter awaits when typing Ctrl+X T
      //   when cursor is located on a test method
      // - one with browser nickname, this is what is needed when re-running a test from
      //   the JUnit view
      // as the list of methods is cached, this is what will be returned when computeTestMethods()
      // is called
      final Description description =
          Description.createTestDescription(getTestClass().getJavaClass(), method.getName());
      final Description description2 =
          Description.createTestDescription(getTestClass().getJavaClass(), testName(method));
      if (!filter.shouldRun(description) && !filter.shouldRun(description2)) {
        iter.remove();
      }
    }
  }
 public void filter(Filter filter) throws NoTestsRemainException {
   if (getTest() instanceof Filterable) {
     Filterable adapter = (Filterable) getTest();
     adapter.filter(filter);
   } else if (getTest() instanceof TestSuite) {
     TestSuite suite = (TestSuite) getTest();
     TestSuite filtered = new TestSuite(suite.getName());
     int n = suite.testCount();
     for (int i = 0; i < n; i++) {
       Test test = suite.testAt(i);
       if (filter.shouldRun(makeDescription(test))) {
         filtered.addTest(test);
       }
     }
     setTest(filtered);
   }
 }
  @Override
  public void filter(Filter filter) throws NoTestsRemainException {
    super.filter(filter);
    List<Description> children = description.getChildren();

    Iterator<Description> itr = children.iterator();
    while (itr.hasNext()) {
      Description child = itr.next();
      if (!filter.shouldRun(child)) {
        itr.remove();
        methodNames.remove(child);
      }
    }

    if (children.isEmpty()) {
      throw new NoTestsRemainException();
    }
  }
Exemple #6
0
 public void filter(Filter filter) throws NoTestsRemainException {
   synchronized (fChildrenLock) {
     List<T> filteredChildren = new ArrayList<T>(getFilteredChildren());
     for (Iterator<T> iter = filteredChildren.iterator(); iter.hasNext(); ) {
       T each = iter.next();
       if (shouldRun(filter, each)) {
         try {
           filter.apply(each);
         } catch (NoTestsRemainException e) {
           iter.remove();
         }
       } else {
         iter.remove();
       }
     }
     fFilteredChildren = Collections.unmodifiableCollection(filteredChildren);
     if (fFilteredChildren.isEmpty()) {
       throw new NoTestsRemainException();
     }
   }
 }
Exemple #7
0
 /* 149:    */
 /* 150:    */ public void filter(Filter filter) /* 151:    */ throws NoTestsRemainException
       /* 152:    */ {
   /* 153:128 */ if ((getTest() instanceof Filterable))
   /* 154:    */ {
     /* 155:129 */ Filterable adapter = (Filterable) getTest();
     /* 156:130 */ adapter.filter(filter);
     /* 157:    */ }
   /* 158:131 */ else if ((getTest() instanceof TestSuite))
   /* 159:    */ {
     /* 160:132 */ TestSuite suite = (TestSuite) getTest();
     /* 161:133 */ TestSuite filtered = new TestSuite(suite.getName());
     /* 162:134 */ int n = suite.testCount();
     /* 163:135 */ for (int i = 0; i < n; i++)
     /* 164:    */ {
       /* 165:136 */ Test test = suite.testAt(i);
       /* 166:137 */ if (filter.shouldRun(makeDescription(test))) {
         /* 167:138 */ filtered.addTest(test);
         /* 168:    */ }
       /* 169:    */ }
     /* 170:140 */ setTest(filtered);
     /* 171:    */ }
   /* 172:    */ }
Exemple #8
0
 private boolean shouldRun(T each) {
   return fFilter == null || fFilter.shouldRun(describeChild(each));
 }
Exemple #9
0
 private void filterChild(T child) throws NoTestsRemainException {
   if (fFilter != null) fFilter.apply(child);
 }
Exemple #10
0
 private boolean shouldRun(Filter filter, T each) {
   return filter.shouldRun(describeChild(each));
 }
 /**
  * Returns a Request that only runs contains tests whose {@link Description} equals <code>
  * desiredDescription</code>
  *
  * @param desiredDescription {@link Description} of those tests that should be run
  * @return the filtered Request
  */
 public Request filterWith(final Description desiredDescription) {
   return filterWith(Filter.matchMethodDescription(desiredDescription));
 }