當前位置: 首頁>>代碼示例>>Java>>正文


Java Filter類代碼示例

本文整理匯總了Java中org.junit.runner.manipulation.Filter的典型用法代碼示例。如果您正苦於以下問題:Java Filter類的具體用法?Java Filter怎麽用?Java Filter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Filter類屬於org.junit.runner.manipulation包,在下文中一共展示了Filter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: allTestsFiltered

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
private boolean allTestsFiltered(Runner runner, List<Filter> filters) {
    LinkedList<Description> queue = new LinkedList<Description>();
    queue.add(runner.getDescription());
    while (!queue.isEmpty()) {
        Description description = queue.removeFirst();
        queue.addAll(description.getChildren());
        boolean run = true;
        for (Filter filter : filters) {
            if (!filter.shouldRun(description)) {
                run = false;
                break;
            }
        }
        if (run) {
            return false;
        }
    }
    return true;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:20,代碼來源:JUnitTestClassExecuter.java

示例2: getTestRequests

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
protected static List<TestRequest> getTestRequests(String folderName, Filter filter) {
    List<TestRequest> requests = new ArrayList<>();
    getTestClasses(folderName).forEach(testClass -> {
        try {
            new BlockJUnit4ClassRunner(testClass).getDescription().getChildren()
                    .forEach(description -> {
                        if (filter.shouldRun(description)) {
                            TestRequest request = new TestRequest(description);
                            request.setTestRunUUID(TestUUID.getTestUUID());
                            requests.add(request);
                        }
                    });
        } catch (InitializationError e) {
            LOGGER.log(e);
        }
    });
    return requests;
}
 
開發者ID:blackboard,項目名稱:lambda-selenium,代碼行數:19,代碼來源:LambdaTestSuite.java

示例3: execute

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
private static void execute( Class<?> testClass, Notifier notifier, Filter filter )
    throws TestSetFailedException
{
    final int classModifiers = testClass.getModifiers();
    if ( !isAbstract( classModifiers ) && !isInterface( classModifiers ) )
    {
        Request request = aClass( testClass );
        if ( filter != null )
        {
            request = request.filterWith( filter );
        }
        Runner runner = request.getRunner();
        if ( countTestsInRunner( runner.getDescription() ) != 0 )
        {
            executeInPlayContext( runner, notifier );
        }
    }
}
 
開發者ID:play1-maven-plugin,項目名稱:play1-maven-plugin,代碼行數:19,代碼來源:PlayJUnit4Provider.java

示例4: filter

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
@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();
		}
	});
}
 
開發者ID:GeeQuery,項目名稱:ef-orm,代碼行數:19,代碼來源:JefJUnit4DatabaseTestRunner.java

示例5: assertFilterLeavesTestUnscathed

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
private void assertFilterLeavesTestUnscathed(Class<?> testClass) {
    Request oneClass = Request.aClass(testClass);
    Request filtered = oneClass.filterWith(new Filter() {
        @Override
        public boolean shouldRun(Description description) {
            return true;
        }

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

    int filterCount = filtered.getRunner().testCount();
    int coreCount = oneClass.getRunner().testCount();
    assertEquals("Counts match up in " + testClass, coreCount, filterCount);
}
 
開發者ID:DIVERSIFY-project,項目名稱:sosiefier,代碼行數:19,代碼來源:MaxStarterTest.java

示例6: findTestUnits

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
@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)) {
    List<TestUnit> filteredUnits = splitIntoFilteredUnits(runner.getDescription());
    return filterUnitsByMethod(filteredUnits);
  } else {
    return Collections.<TestUnit> singletonList(new AdaptedJUnitTestUnit(
        clazz, Option.<Filter> none()));
  }
}
 
開發者ID:hcoles,項目名稱:pitest,代碼行數:19,代碼來源:JUnitCustomRunnerTestUnitFinder.java

示例7: createFilter

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
private Option<Filter> createFilter(final Class<?> clazz, final String method) {
  final Description d = Description.createTestDescription(clazz, method);
  final Filter f = new Filter() {

    @Override
    public boolean shouldRun(final Description description) {
      return d.toString().equals(description.toString());
    }

    @Override
    public String describe() {
      return null;
    }

  };
  return Option.some(f);
}
 
開發者ID:hcoles,項目名稱:pitest,代碼行數:18,代碼來源:AdaptedJUnitTestUnitTest.java

示例8: simulateSelfRandomizingTestRun

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
/**
 * Simulates test sharding with the given filters and test descriptions, for a
 * set of test descriptions that is in a different order in every test shard.
 *
 * @param filters a list of filters, one per test shard
 * @param descriptions a list of test descriptions
 * @return a mapping from each filter to the descriptions of the tests that would be run
 *   by the shard associated with that filter.
 */
protected static Map<Filter, List<Description>> simulateSelfRandomizingTestRun(
    List<Filter> filters, List<Description> descriptions) {
  if (descriptions.isEmpty()) {
    return new HashMap<>();
  }
  Deque<Description> mutatingDescriptions = new LinkedList<>(descriptions);
  Map<Filter, List<Description>> descriptionsRun = new HashMap<>();

  for (Filter filter : filters) {
    // rotate the queue so that each filter gets the descriptions in a different order
    mutatingDescriptions.addLast(mutatingDescriptions.pollFirst());
    for (Description description : descriptions) {
      if (filter.shouldRun(description)) {
        addDescriptionForFilterToMap(descriptionsRun, filter, description);
      }
    }
  }
  return descriptionsRun;
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:29,代碼來源:ShardingFilterTestCase.java

示例9: testCreateShardingFilter_defaultStrategy

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
@Test
public void testCreateShardingFilter_defaultStrategy() {
  List<Description> descriptions = ShardingFilterTestCase.createGenericTestCaseDescriptions(6);
  RoundRobinShardingFilter expectedFilter = new RoundRobinShardingFilter(descriptions, 0, 5);

  when(mockShardingEnvironment.getShardIndex()).thenReturn(0);
  when(mockShardingEnvironment.getTotalShards()).thenReturn(5);
  when(mockShardingEnvironment.getTestShardingStrategy()).thenReturn(null);

  ShardingFilters shardingFilters = new ShardingFilters(mockShardingEnvironment,
      ShardingFilters.ShardingStrategy.ROUND_ROBIN);
  Filter filter = shardingFilters.createShardingFilter(descriptions);

  assertThat(filter).isInstanceOf(RoundRobinShardingFilter.class);
  RoundRobinShardingFilter shardingFilter = (RoundRobinShardingFilter) filter;
  assertThat(shardingFilter.testToShardMap).isEqualTo(expectedFilter.testToShardMap);
  assertThat(shardingFilter.shardIndex).isEqualTo(expectedFilter.shardIndex);
  assertThat(shardingFilter.totalShards).isEqualTo(expectedFilter.totalShards);
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:20,代碼來源:ShardingFiltersTest.java

示例10: HavaRunner_supports_the_JUnit_filter_API_even_when_the_test_contains_scenarios

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
@Test
public void HavaRunner_supports_the_JUnit_filter_API_even_when_the_test_contains_scenarios() {
    HavaRunner havaRunner = new HavaRunner(TestClassWithScenarios.class);
    havaRunner.filter(new Filter() {
        public boolean shouldRun(Description description) {
            throw new UnsupportedOperationException("HavaRunner should not call this method");
        }

        public String describe() {
            return String.format("Method HavaRunner_should_run_only_this_method(%s)", TestClassWithScenarios.class.getName());
        }
    });
    run(havaRunner);
    assertEquals(Sets.newHashSet("first scenario", "second scenario"), TestClassWithScenarios.filteredTestCalledForScenarios);
    assertEquals(Sets.newHashSet(), TestClassWithScenarios.rejectedTestCalledForScenarios);
}
 
開發者ID:havarunner,項目名稱:havarunner,代碼行數:17,代碼來源:FilterTest.java

示例11: initExecutions

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
private void initExecutions() {
    if (!executionsInitialized) {
        try {
            Runner descriptionProvider = createRunnerFor(Arrays.asList(target), Collections.<Filter>emptyList());
            templateDescription = descriptionProvider.getDescription();
        } catch (InitializationError initializationError) {
            throw UncheckedException.throwAsUncheckedException(initializationError);
        }
        createExecutions();
        for (Execution execution : executions) {
            execution.init(target, templateDescription);
        }
        executionsInitialized = true;
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:16,代碼來源:AbstractMultiTestRunner.java

示例12: runEnabledTests

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
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);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:33,代碼來源:AbstractMultiTestRunner.java

示例13: populateDescriptionRunningMap

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
private void populateDescriptionRunningMap(Description description, Map<Description, Boolean> accumulator, Filter filter) {
    if(description.isTest()) {
        Boolean shouldRunStatus = filter.shouldRun(description);
        accumulator.put(description, shouldRunStatus);
        return;
    }
    List<Description> children = description.getChildren();
    for(Description d : children) {
        populateDescriptionRunningMap(d, accumulator, filter);
    }
}
 
開發者ID:MarkBramnik,項目名稱:rtest,代碼行數:12,代碼來源:FilterDataCreator.java

示例14: getFilter

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
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";
           }
       };*/

}
 
開發者ID:MarkBramnik,項目名稱:rtest,代碼行數:36,代碼來源:FilterData.java

示例15: addFilter

import org.junit.runner.manipulation.Filter; //導入依賴的package包/類
private void addFilter(Filter filter) {
  try {
    filter(filter);
  } catch (NoTestsRemainException ex) {
    System.out.println("No tests remain exception: " + ex);
  }
}
 
開發者ID:google,項目名稱:wycheproof,代碼行數:8,代碼來源:WycheproofRunner.java


注:本文中的org.junit.runner.manipulation.Filter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。