org.junit.runner.Description#isSuite()源码实例Demo

下面列出了org.junit.runner.Description#isSuite() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: n4js   文件: DescriptionTester.java
@Override
public boolean test(Object receiver, String property, Object[] args,
		Object expectedValue) {

	if (receiver instanceof IStructuredSelection == false) {
		return false;
	}

	Object element = ((IStructuredSelection) receiver).getFirstElement();

	if (element == null || element instanceof Description == false) {
		return false;
	}

	Description description = (Description) element;

	if (property.equals("isTest")) {
		return description.isTest();
	}

	if (property.equals("isSuite")) {
		return description.isSuite();
	}

	return false;
}
 
源代码2 项目: n4js   文件: XpectLabelProvider.java
@Override
public String getText(Object element) {

	if (element instanceof Description == false) {
		return "";
	}

	Description desc = ((Description) element);

	if (desc.isSuite()) {
		return N4IDEXpectFileNameUtil.getSuiteName(desc);
	}

	if (desc.isTest()) {
		return N4IDEXpectFileNameUtil.getTestName(desc);
	}

	return "";
}
 
源代码3 项目: n4js   文件: XpectLabelProvider.java
/**
 * get icon based on item type (test/suite) and its status (pass/failed/exception/skip/in progress...)
 */
private ImageDescriptor getImageDescriptor(Object element) throws RuntimeException {
	ImageDescriptor descriptor = null;
	if (element instanceof Description == false) {
		String msg = "Unknown type of element in tree of type " + element.getClass().getName();
		Exception e = new RuntimeException(msg);
		N4IDEXpectUIPlugin.logError("cannot obtain image descriptor, fallback to default", e);
		return getImageDescriptor("n4_logo.png");
	}

	Description desc = (Description) element;

	if (desc.isTest()) {
		descriptor = getTestImageDescriptor(executionStatus.getStatus(desc));
	} else if (desc.isSuite()) {
		descriptor = getSuiteImageDescriptor(desc, executionStatus.getStatus(desc));
	} else {
		descriptor = getImageDescriptor("n4_logo.png");
	}
	return descriptor;
}
 
源代码4 项目: lucene-solr   文件: TestRuleStoreClassName.java
@Override
public Statement apply(final Statement s, final Description d) {
  if (!d.isSuite()) {
    throw new IllegalArgumentException("This is a @ClassRule (applies to suites only).");
  }

  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      try {
        description = d; 
        s.evaluate();
      } finally {
        description = null;
      }
    }
  };
}
 
源代码5 项目: phoenix   文件: RunUntilFailure.java
private void runRepeatedly(Statement statement, Description description,  
        RunNotifier notifier) {
    notifier.addListener(new RunListener() {
        @Override
        public void testFailure(Failure failure) {
            hasFailure = true;
        }
    });
    for (Description desc : description.getChildren()) {  
        if (hasFailure) {
            notifier.fireTestIgnored(desc);
        } else if(!desc.isSuite()) {
            runLeaf(statement, desc, notifier);
        }
    }  
}
 
@Override
public Statement apply(final Statement base, final Description description) {
	if (!description.isSuite()) {
		return base;
	}
	suiteName = description.getDisplayName();
	return new Statement() {
		@Override
		public void evaluate() throws Throwable {
			runner = new EvictionBenchmarkRunner(suiteName);
			if (readStoredResults) {
				runner.readEvaluationResults();
			}
			base.evaluate();
			runner.printRankingSummary(candidate, peers);
		}
	};
}
 
源代码7 项目: n4js   文件: N4IDEXpectFileNameUtil.java
/***/
public static String getSuiteName(Description description) {
	String text = null;
	if (description.isSuite()) {
		String s = description.getDisplayName();
		int posSemi = s.indexOf(":");
		text = s.substring(0, posSemi);
	}
	return text;
}
 
源代码8 项目: allure-cucumberjvm   文件: AllureRunListener.java
@Override
public void testFinished(Description description) throws IllegalAccessException {
    if (description.isSuite()) {
        testSuiteFinished(getSuiteUid(description));
    } else {
        getLifecycle().fire(new TestCaseFinishedEvent());
    }
}
 
源代码9 项目: allure-cucumberjvm   文件: AllureRunListener.java
public String getSuiteUid(Description description) throws IllegalAccessException {
    String suiteName = description.getClassName();
    if (!description.isSuite()) {
        suiteName = extractClassName(description);
    }
    if (!getSuites().containsKey(suiteName)) {
        //Fix NPE
        Description suiteDescription = Description.createSuiteDescription(suiteName);
        testSuiteStarted(suiteDescription, suiteName);
    }
    return getSuites().get(suiteName);
}
 
源代码10 项目: ehcache3   文件: ParallelTestCluster.java
@Override
public Statement apply(Statement base, Description description) {
  if (description.isSuite()) {
    return cluster.apply(base, description);
  } else if (description.isTest()) {
    return new Statement() {
      @Override
      public void evaluate() throws Throwable {
        membership.register();
        Thread.sleep(100);
        membership.awaitAdvanceInterruptibly(membership.arrive());
        try {
          activeCycle.awaitAdvanceInterruptibly(activeCycle.arrive());
          try {
            base.evaluate();
          } finally {
            activeCycle.arriveAndDeregister();
          }
        } finally {
          membership.arriveAndDeregister();
        }
      }
    };
  } else {
    return base;
  }
}
 
源代码11 项目: bazel   文件: RegExTestCaseFilter.java
@Override
public boolean shouldRun(Description description) {
  if (description.isSuite()) {
    return true;
  }

  boolean match = pattern.matcher(formatDescriptionName(description)).find();
  return isNegated ? !match : match;
}
 
源代码12 项目: bazel   文件: JUnit4TestModelBuilder.java
/**
 * Creates a model for a JUnit4 suite. This can be expensive; callers should
 * consider memoizing the result.
 *
 * @return model.
 */
@Override
public TestSuiteModel get() {
  Description root = request.getRunner().getDescription();
  // A test class annotated with @Ignore effectively has no test methods,
  // which is what isSuite() tests for.
  if (!root.isSuite()) {
    return builder.build(suiteName);
  } else {
    return builder.build(suiteName, root);
  }
}
 
源代码13 项目: bazel   文件: HashBackedShardingFilter.java
@Override
public boolean shouldRun(Description description) {
  if (description.isSuite()) {
    return true;
  }
  int mod = description.getDisplayName().hashCode() % totalShards;
  if (mod < 0) {
    mod += totalShards;
  }
  if (mod < 0 || mod >= totalShards) {
    throw new IllegalStateException();
  }

  return mod == shardIndex;
}
 
源代码14 项目: bazel   文件: RoundRobinShardingFilter.java
@Override
public boolean shouldRun(Description description) {
  if (description.isSuite()) {
    return true;
  }
  Integer testNumber = testToShardMap.get(description);
  if (testNumber == null) {
    throw new IllegalArgumentException("This filter keeps a mapping from each test "
        + "description to a shard, and the given description was not passed in when "
        + "filter was constructed: " + description);
  }
  return (testNumber % totalShards) == shardIndex;
}
 
源代码15 项目: bazel   文件: FakeShardingFilters.java
@Override
public boolean shouldRun(Description description) {
  if (description.isSuite()) {
    return true;
  }
  if (!allDescriptions.contains(description)) {
    throw new IllegalArgumentException("Not in the suite: " + description);
  }
  return descriptionsToRun.contains(description);
}
 
源代码16 项目: cache2k   文件: CacheRule.java
@Override
public Statement apply(final Statement st, final Description d) {
  if (d.isSuite()) {
    shared = true;
    description = d;
    return new Statement() {
      @Override
      public void evaluate() throws Throwable {
        try {
          st.evaluate();
        } finally {
          cleanupClass();
        }
      }
    };
  }
  if (d.isTest()) {
    description = d;
    return new Statement() {
      @Override
      public void evaluate() throws Throwable {
        try {
          st.evaluate();
        } finally {
          cleanupMethod();
        }
      }
    };
  }
  throw new UnsupportedOperationException("hey?");
}
 
源代码17 项目: n4js   文件: GenerateXpectReportCommandHandler.java
/**
 * When called will check if provided data contains {@link Description test description} with failed status stored
 * in {@link N4IDEXpectView test view}. If that holds, will generate data for bug report in a console view,
 * otherwise will show message to reconfigure and rerun Xpect tests.
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);

	IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
	try {
		view = (N4IDEXpectView) windows[0].getActivePage().showView(
				N4IDEXpectView.ID);
	} catch (PartInitException e) {
		N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
	}

	Description desc = (Description) selection.getFirstElement();

	// handle failed suite
	if (desc.isSuite()) {
		final N4IDEXpectView finalview = view;

		boolean suitePassed = desc.getChildren().stream()
				.noneMatch(childDescription -> finalview.testsExecutionStatus.hasFailed(childDescription));

		if (suitePassed) {
			XpectFileContentsUtil.getXpectFileContentAccess(desc).ifPresent(
					xpectFielContentAccess -> {
						if (xpectFielContentAccess.containsFixme()) {
							generateAndDisplayReport(
									N4IDEXpectFileNameUtil.getSuiteName(desc),
									xpectFielContentAccess.getContetns());
						}
					});

		} else {
			XpectConsole console = ConsoleDisplayMgr.getOrCreate("generated bug for "
					+ N4IDEXpectFileNameUtil.getSuiteName(desc));
			console.clear();
			String ls = System.lineSeparator();
			console.log("Suite must be passing and contain XPECT FIXME marker to be submited bug report. Please :"
					+ ls + " - fix failing tests" + ls + " - mark test in question with XPECT FIXME");
		}
	}

	return null;
}
 
源代码18 项目: bazel   文件: JUnit4TestXmlListener.java
private boolean isSuiteAssumptionFailure(Description description) {
  return description.isSuite() && description.getAnnotation(Ignore.class) == null;
}