Java Code Examples for org.junit.runner.Description#isSuite()
The following examples show how to use
org.junit.runner.Description#isSuite() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EvictionBenchmarkRunnerRule.java From cache2k-benchmark with Apache License 2.0 | 6 votes |
@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); } }; }
Example 2
Source File: XpectLabelProvider.java From n4js with Eclipse Public License 1.0 | 6 votes |
@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 ""; }
Example 3
Source File: XpectLabelProvider.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * 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; }
Example 4
Source File: TestRuleStoreClassName.java From lucene-solr with Apache License 2.0 | 6 votes |
@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; } } }; }
Example 5
Source File: RunUntilFailure.java From phoenix with Apache License 2.0 | 6 votes |
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); } } }
Example 6
Source File: DescriptionTester.java From n4js with Eclipse Public License 1.0 | 6 votes |
@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; }
Example 7
Source File: RegExTestCaseFilter.java From bazel with Apache License 2.0 | 5 votes |
@Override public boolean shouldRun(Description description) { if (description.isSuite()) { return true; } boolean match = pattern.matcher(formatDescriptionName(description)).find(); return isNegated ? !match : match; }
Example 8
Source File: CacheRule.java From cache2k with Apache License 2.0 | 5 votes |
@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?"); }
Example 9
Source File: FakeShardingFilters.java From bazel with Apache License 2.0 | 5 votes |
@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); }
Example 10
Source File: RoundRobinShardingFilter.java From bazel with Apache License 2.0 | 5 votes |
@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; }
Example 11
Source File: HashBackedShardingFilter.java From bazel with Apache License 2.0 | 5 votes |
@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; }
Example 12
Source File: JUnit4TestModelBuilder.java From bazel with Apache License 2.0 | 5 votes |
/** * 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); } }
Example 13
Source File: ParallelTestCluster.java From ehcache3 with Apache License 2.0 | 5 votes |
@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; } }
Example 14
Source File: AllureRunListener.java From allure-cucumberjvm with Apache License 2.0 | 5 votes |
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); }
Example 15
Source File: AllureRunListener.java From allure-cucumberjvm with Apache License 2.0 | 5 votes |
@Override public void testFinished(Description description) throws IllegalAccessException { if (description.isSuite()) { testSuiteFinished(getSuiteUid(description)); } else { getLifecycle().fire(new TestCaseFinishedEvent()); } }
Example 16
Source File: N4IDEXpectFileNameUtil.java From n4js with Eclipse Public License 1.0 | 5 votes |
/***/ 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; }
Example 17
Source File: JUnit4TestXmlListener.java From bazel with Apache License 2.0 | 4 votes |
private boolean isSuiteAssumptionFailure(Description description) { return description.isSuite() && description.getAnnotation(Ignore.class) == null; }
Example 18
Source File: GenerateXpectReportCommandHandler.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** * 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; }