Java Examples for org.junit.runner.Description

The following java examples will help you to understand the usage of org.junit.runner.Description. These source code samples are taken from different open source projects.

Example 1
Project: eclipselink.runtime-master  File: SerializableDescription.java View source code
/**
     * Create a SerializableDescription objects from an org.junit.runner.Description objects
     * @param description the org.junit.runner.Description object to be converted
     * @return the SerializableDescription object created from an org.junit.runner.Description object
     */
@SuppressWarnings("unchecked")
public static SerializableDescription create(Description description) {
    final List<SerializableDescription> children;
    if (description.getChildren() != null) {
        children = new ArrayList<SerializableDescription>();
        for (Description child : description.getChildren()) {
            children.add(create(child));
        }
    } else {
        children = Collections.EMPTY_LIST;
    }
    return new SerializableDescription(description.getDisplayName(), children);
}
Example 2
Project: org.openntf.domino-master  File: JUnit4TestAdapter.java View source code
private Description removeIgnored(Description description) {
    if (isIgnored(description)) {
        return Description.EMPTY;
    }
    Description result = description.childlessCopy();
    for (Description each : description.getChildren()) {
        Description child = removeIgnored(each);
        if (!child.isEmpty()) {
            result.addChild(child);
        }
    }
    return result;
}
Example 3
Project: RoboBuggy-master  File: PrintableResultTest.java View source code
@Theory(nullsAccepted = false)
public void backTraceHasGoodToString(String descriptionName, final String stackTraceClassName) {
    Failure failure = new Failure(Description.createSuiteDescription(descriptionName), new Throwable() {

        private static final long serialVersionUID = 1L;

        @Override
        public StackTraceElement[] getStackTrace() {
            return new StackTraceElement[] { new StackTraceElement(stackTraceClassName, "methodName", "fileName", 1) };
        }
    });
    assertThat(new PrintableResult(asList(failure)).toString(), allOf(containsString(descriptionName), containsString(stackTraceClassName)));
}
Example 4
Project: sosies-generator-master  File: PrintableResultTest.java View source code
@Theory(nullsAccepted = false)
public void backTraceHasGoodToString(String descriptionName, final String stackTraceClassName) {
    Failure failure = new Failure(Description.createSuiteDescription(descriptionName), new Throwable() {

        private static final long serialVersionUID = 1L;

        @Override
        public StackTraceElement[] getStackTrace() {
            return new StackTraceElement[] { new StackTraceElement(stackTraceClassName, "methodName", "fileName", 1) };
        }
    });
    assertThat(new PrintableResult(asList(failure)).toString(), allOf(containsString(descriptionName), containsString(stackTraceClassName)));
}
Example 5
Project: fluent-http-master  File: RunMultipleTimes.java View source code
@Override
public Statement apply(Statement statement, Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            for (int i = 0; i < times; i++) {
                System.out.printf("Run #%02d%n", i);
                statement.evaluate();
            }
        }
    };
}
Example 6
Project: substeps-eclipse-plugin-master  File: JUnit4TestClassReference.java View source code
private void sendDescriptionTree(final IVisitsTestTrees notified, final org.junit.runner.Description description) {
    if (description.isTest()) {
        notified.visitTreeEntry(new JUnit4Identifier(description), false, 1);
    } else {
        notified.visitTreeEntry(new JUnit4Identifier(description), true, description.getChildren().size());
        for (final Description child : description.getChildren()) {
            sendDescriptionTree(notified, child);
        }
    }
}
Example 7
Project: eclipse.jdt.ui-master  File: SubForestFilter.java View source code
private boolean collectIncludedDescriptions(Description description) {
    if (fMatcher.matches(description)) {
        includeWithChildren(description);
        return true;
    }
    boolean hasIncludedChild = false;
    for (Description child : description.getChildren()) {
        hasIncludedChild |= collectIncludedDescriptions(child);
    }
    if (hasIncludedChild) {
        this.fIncluded.add(description);
    }
    return hasIncludedChild;
}
Example 8
Project: powermock-master  File: PowerMockJUnit4LegacyFilter.java View source code
/**
	 * [email protected]}
	 */
@Override
public boolean shouldRun(Description description) {
    boolean shouldRun = false;
    for (String testMethodName : methodNamesToRun) {
        if (testMethodName.equals(extractMethodName(description))) {
            shouldRun = true;
            break;
        }
    }
    return shouldRun;
}
Example 9
Project: lucene-solr-master  File: TestJUnitRuleOrder.java View source code
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            stack.push("@Rule before");
            base.evaluate();
            stack.push("@Rule after");
        }
    };
}
Example 10
Project: CallBuilder-master  File: JUnit4TestAdapter.java View source code
private Description removeIgnored(Description description) {
    if (isIgnored(description)) {
        return Description.EMPTY;
    }
    Description result = description.childlessCopy();
    for (Description each : description.getChildren()) {
        Description child = removeIgnored(each);
        if (!child.isEmpty()) {
            result.addChild(child);
        }
    }
    return result;
}
Example 11
Project: js-android-app-master  File: DatabaseRule.java View source code
@Override
public final Statement apply(final Statement base, Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            resetDatabase();
            base.evaluate();
            resetDatabase();
        }
    };
}
Example 12
Project: kouchat-android-master  File: ExpectedSystemOut.java View source code
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            beforeSetUp();
            try {
                base.evaluate();
            } finally {
                afterTearDown();
            }
        }
    };
}
Example 13
Project: keycloak-master  File: TestEventsLogger.java View source code
private void createPageSrcFile(Description d) throws IOException {
    if (driver != null && driver.getPageSource() != null) {
        String pageSourceLocation = System.getProperty("page.source.location", "target/failed-tests/page-source/");
        FileUtils.writeStringToFile(new File(pageSourceLocation + d.getTestClass().getSimpleName() + "/" + d.getMethodName() + ".html"), driver.getPageSource());
    }
}
Example 14
Project: k3po-master  File: ServerBootstrapRule.java View source code
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            bootstrap = bootstrapFactory.newServerBootstrap(transportName);
            try {
                base.evaluate();
            } finally {
                bootstrapFactory.shutdown();
                bootstrapFactory.releaseExternalResources();
            }
        }
    };
}
Example 15
Project: arquillian-core-master  File: TestingTestRuleInnerStatement.java View source code
@Override
public Statement apply(final Statement base, Description description) {
    assertNotNull(ruleResources);
    return new Statement() {

        @ArquillianResource
        private ResourceStub statementResources;

        @Override
        public void evaluate() throws Throwable {
            ResourceAssertion.assertNotNullAndNotEqual(statementResources, ruleResources);
            base.evaluate();
        }
    };
}
Example 16
Project: keywhiz-master  File: MigrationsRule.java View source code
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            File yamlFile = new File(Resources.getResource("keywhiz-test.yaml").getFile());
            Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
            ObjectMapper objectMapper = KeywhizService.customizeObjectMapper(Jackson.newObjectMapper());
            KeywhizConfig config = new ConfigurationFactory<>(KeywhizConfig.class, validator, objectMapper, "dw").build(yamlFile);
            DataSource dataSource = config.getDataSourceFactory().build(new MetricRegistry(), "db-migrations");
            Flyway flyway = new Flyway();
            flyway.setDataSource(dataSource);
            flyway.setLocations(config.getMigrationsDir());
            flyway.clean();
            flyway.migrate();
            DSLContext dslContext = DSLContexts.databaseAgnostic(dataSource);
            DbSeedCommand.doImport(dslContext);
            base.evaluate();
        }
    };
}
Example 17
Project: idnadrev-master  File: FXTestRunner.java View source code
@Override
public void run(RunNotifier notifier) {
    if (TestApp.instance == null) {
        synchronized (TestApp.class) {
            executorService.submit(() -> Application.launch(TestApp.class));
        }
    }
    while (TestApp.instance == null) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
        }
    }
    notifier.addListener(new RunListener() {

        @Override
        public void testStarted(Description description) throws Exception {
            super.testStarted(description);
            log.info("@Test:{}.{}", description.getClassName(), description.getMethodName());
        }
    });
    super.run(notifier);
}
Example 18
Project: usergrid-master  File: ServiceITSetupImpl.java View source code
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            before(description);
            try {
                base.evaluate();
            } finally {
                after(description);
            }
        }
    };
}
Example 19
Project: framework-master  File: RetryOnFail.java View source code
private Statement statement(final Statement base, final Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            Throwable caughtThrowable = null;
            int retryCount = getRetryCount();
            for (int i = 0; i <= retryCount; i++) {
                try {
                    base.evaluate();
                    return;
                } catch (Throwable t) {
                    caughtThrowable = t;
                    System.err.println(String.format("%s: run %s/%s failed.", description.getDisplayName(), i + 1, retryCount + 1));
                    System.err.println(t.getMessage());
                }
            }
            throw caughtThrowable;
        }

        private int getRetryCount() {
            String retryCount = System.getProperty("com.vaadin.testbench.max.retries");
            if (retryCount != null && retryCount != "") {
                return Integer.parseInt(retryCount);
            }
            return 0;
        }
    };
}
Example 20
Project: lcm-master  File: JUnit4TestAdapter.java View source code
private Description removeIgnored(Description description) {
    if (isIgnored(description)) {
        return Description.EMPTY;
    }
    Description result = description.childlessCopy();
    for (Description each : description.getChildren()) {
        Description child = removeIgnored(each);
        if (!child.isEmpty()) {
            result.addChild(child);
        }
    }
    return result;
}
Example 21
Project: jumi-master  File: TestingExecutor.java View source code
@Override
public Statement apply(Statement base, Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            try {
                base.evaluate();
            } catch (Throwable t) {
                throw withUncaughtExceptions(t);
            } finally {
                shutdownNow();
            }
            boolean terminated = awaitTermination(1000, TimeUnit.MILLISECONDS);
            if (!uncaughtExceptions.isEmpty()) {
                throw withUncaughtExceptions(new AssertionError("There were uncaught exceptions in executor threads"));
            }
            assertTrue("Executor did not terminate properly", terminated);
        }
    };
}
Example 22
Project: flink-master  File: TestLogger.java View source code
@Override
public void starting(Description description) {
    log.info("\n================================================================================" + "\nTest {} is running." + "\n--------------------------------------------------------------------------------", description);
}
Example 23
Project: cloudtm-data-platform-master  File: RequiresTransactionalCapabilitiesRule.java View source code
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            if (TestHelper.backendSupportsTransactions()) {
                base.evaluate();
            } else {
                log.info("Skipping test " + description.getMethodName() + " as the current GridDialect doesn't support transactions");
            }
        }
    };
}
Example 24
Project: tinkerpop-master  File: GremlinProcessRunner.java View source code
@Override
public void runChild(final FrameworkMethod method, final RunNotifier notifier) {
    final Description description = describeChild(method);
    if (this.isIgnored(method)) {
        notifier.fireTestIgnored(description);
    } else {
        EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
        eachNotifier.fireTestStarted();
        boolean ignored = false;
        try {
            this.methodBlock(method).evaluate();
        } catch (AssumptionViolatedException ave) {
            eachNotifier.addFailedAssumption(ave);
        } catch (Throwable e) {
            if (validateForGraphComputer(e)) {
                eachNotifier.fireTestIgnored();
                logger.info(e.getMessage());
                ignored = true;
            } else
                eachNotifier.addFailure(e);
        } finally {
            if (!ignored)
                eachNotifier.fireTestFinished();
        }
    }
}
Example 25
Project: swtbot-master  File: ScreenshotCaptureListener.java View source code
/**
	 * Removes a previously taken screenshot, if any.
	 *
	 * @param description
	 *            of the test
	 * @since 2.4
	 */
public void removeScreenshot(Description description) {
    File file = new File(getFileName(new Failure(description, null)));
    if (file.exists()) {
        //$NON-NLS-1$
        log.debug("Removing screenshot '" + file.getPath() + '\'');
        if (!file.delete() && file.exists()) {
            //$NON-NLS-1$
            log.warn(//$NON-NLS-1$
            "Could not remove screenshot " + file.getAbsolutePath());
        }
        --screenshotCounter;
    }
}