本文整理匯總了Java中org.junit.runner.manipulation.Filter.shouldRun方法的典型用法代碼示例。如果您正苦於以下問題:Java Filter.shouldRun方法的具體用法?Java Filter.shouldRun怎麽用?Java Filter.shouldRun使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.junit.runner.manipulation.Filter
的用法示例。
在下文中一共展示了Filter.shouldRun方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例2: 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();
}
});
}
示例3: 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;
}
示例4: 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);
}
}
示例5: filterAppliesToAny
import org.junit.runner.manipulation.Filter; //導入方法依賴的package包/類
private static boolean filterAppliesToAny(Description d, Filter f) {
if (f.shouldRun(d)) {
return true;
}
for (Description c : d.getChildren()) {
if (filterAppliesToAny(c, f)) {
return true;
}
}
return false;
}
示例6: shouldRun
import org.junit.runner.manipulation.Filter; //導入方法依賴的package包/類
private boolean shouldRun(Filter filter, FrameworkMethod each) {
if (filter.shouldRun(describeChild(each))) {
return true;
}
String testDescribe = PinpointPluginTestUtils.getTestDescribe(each.getMethod());
return testDescribe.equals(filter.describe());
}
示例7: shouldRun
import org.junit.runner.manipulation.Filter; //導入方法依賴的package包/類
private boolean shouldRun(Filter filter, Runner each) {
if (filter.shouldRun(describeChild(each))) {
return true;
}
if (each instanceof PinpointPluginTestRunner) {
return ((PinpointPluginTestRunner) each).isAvaiable(filter);
}
return false;
}
示例8: getFilteredDescription
import org.junit.runner.manipulation.Filter; //導入方法依賴的package包/類
private static Description getFilteredDescription(Request request, Description description) throws NoSuchFieldException, IllegalAccessException {
final Field field = FilterRequest.class.getDeclaredField("fFilter");
field.setAccessible(true);
final Filter filter = (Filter)field.get(request);
final String filterDescription = filter.describe();
if (filterDescription != null) {
boolean isMethodFilter = filterDescription.startsWith("Method");
if (isMethodFilter && canCompress(description)) return (Description)description.getChildren().get(0);
try {
final Description failedTestsDescription = Description.createSuiteDescription(filterDescription, null);
if (filterDescription.startsWith("Tests") || filterDescription.startsWith("Ignored")) {
for (Iterator iterator = description.getChildren().iterator(); iterator.hasNext(); ) {
final Description childDescription = (Description)iterator.next();
if (filter.shouldRun(childDescription)) {
failedTestsDescription.addChild(childDescription);
}
}
description = failedTestsDescription;
} else if (isMethodFilter && canCompress(failedTestsDescription)) {
description = (Description)failedTestsDescription.getChildren().get(0);
}
}
catch (NoSuchMethodError e) {
//junit 4.0 doesn't have method createSuite(String, Annotation...) : skip it
}
}
return description;
}
示例9: simulateTestRun
import org.junit.runner.manipulation.Filter; //導入方法依賴的package包/類
/**
* Simulates test sharding with the given filters and test descriptions.
*
* @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>> simulateTestRun(List<Filter> filters,
List<Description> descriptions) {
Map<Filter, List<Description>> descriptionsRun = new HashMap<>();
for (Filter filter : filters) {
for (Description description : descriptions) {
if (filter.shouldRun(description)) {
addDescriptionForFilterToMap(descriptionsRun, filter, description);
}
}
}
return descriptionsRun;
}
示例10: shouldRun
import org.junit.runner.manipulation.Filter; //導入方法依賴的package包/類
private boolean shouldRun(Filter filter, FrameworkMethod each) {
return filter.shouldRun(describeOriginalChild(each));
}
示例11: shouldRun
import org.junit.runner.manipulation.Filter; //導入方法依賴的package包/類
private boolean shouldRun(Filter filter, T each) {
return filter.shouldRun(describeChild(each));
}
示例12: shouldRun
import org.junit.runner.manipulation.Filter; //導入方法依賴的package包/類
private boolean shouldRun(Filter filter, T each) {
return filter.shouldRun(describeChild(each));
}
示例13: assertThrowsExceptionForUnknownDescription
import org.junit.runner.manipulation.Filter; //導入方法依賴的package包/類
protected static void assertThrowsExceptionForUnknownDescription(Filter filter) {
try {
filter.shouldRun(Description.createTestDescription(Object.class, "unknown"));
fail("expected thrown exception");
} catch (IllegalArgumentException expected) { }
}
示例14: shouldRun
import org.junit.runner.manipulation.Filter; //導入方法依賴的package包/類
private boolean shouldRun(Filter filter, FrameworkMethod each) {
return filter.shouldRun(describeChild(each));
}