Search in sources :

Example 1 with Suite

use of org.junit.runners.Suite in project intellij-community by JetBrains.

the class IdeaSuite method skipSuiteComponents.

private void skipSuiteComponents(Set allNames, Object child) {
    try {
        if (child instanceof Suite) {
            final Method getChildrenMethod = Suite.class.getDeclaredMethod("getChildren", new Class[0]);
            getChildrenMethod.setAccessible(true);
            final List tests = (List) getChildrenMethod.invoke(child, new Object[0]);
            for (Iterator suiteIterator = tests.iterator(); suiteIterator.hasNext(); ) {
                final String displayName = describeChild((Runner) suiteIterator.next()).getDisplayName();
                if (allNames.contains(displayName)) {
                    allNames.remove(displayName);
                }
            }
        } else if (child instanceof SuiteMethod) {
            final Method getChildrenMethod = JUnit38ClassRunner.class.getDeclaredMethod("getTest", new Class[0]);
            getChildrenMethod.setAccessible(true);
            final Test test = (Test) getChildrenMethod.invoke(child, new Object[0]);
            if (test instanceof TestSuite) {
                final Enumeration tests = ((TestSuite) test).tests();
                while (tests.hasMoreElements()) {
                    final Test t = (Test) tests.nextElement();
                    if (t instanceof TestSuite) {
                        final String testDescription = ((TestSuite) t).getName();
                        if (allNames.contains(testDescription)) {
                            allNames.remove(testDescription);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) Runner(org.junit.runner.Runner) ParentRunner(org.junit.runners.ParentRunner) JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) SuiteMethod(org.junit.internal.runners.SuiteMethod) SuiteMethod(org.junit.internal.runners.SuiteMethod) Method(java.lang.reflect.Method) TestSuite(junit.framework.TestSuite) Suite(org.junit.runners.Suite) TestSuite(junit.framework.TestSuite) Test(junit.framework.Test)

Example 2 with Suite

use of org.junit.runners.Suite in project jena by apache.

the class ManifestSuite method oneManifest.

private Runner oneManifest(final Manifest manifest, List<Runner> r) {
    // Recurse
    for (Iterator<String> iter = manifest.includedManifests(); iter.hasNext(); ) {
        try {
            r.add(oneManifest(new Manifest(iter.next()), new ArrayList<Runner>()));
        } catch (JenaException ex) {
            r.add(new ErrorReportingRunner(null, ex));
        }
    }
    itemHandler.setTestRunnerList(r);
    manifest.apply(itemHandler);
    try {
        return new Suite((Class<?>) null, r) {

            @Override
            protected String getName() {
                return manifest.getName();
            }
        };
    } catch (InitializationError e) {
        return new ErrorReportingRunner(null, e);
    }
}
Also used : Suite(org.junit.runners.Suite) JenaException(org.apache.jena.shared.JenaException) InitializationError(org.junit.runners.model.InitializationError) ArrayList(java.util.ArrayList) ErrorReportingRunner(org.junit.internal.runners.ErrorReportingRunner)

Aggregations

Suite (org.junit.runners.Suite)2 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Test (junit.framework.Test)1 TestSuite (junit.framework.TestSuite)1 JenaException (org.apache.jena.shared.JenaException)1 ErrorReportingRunner (org.junit.internal.runners.ErrorReportingRunner)1 JUnit38ClassRunner (org.junit.internal.runners.JUnit38ClassRunner)1 SuiteMethod (org.junit.internal.runners.SuiteMethod)1 Runner (org.junit.runner.Runner)1 ParentRunner (org.junit.runners.ParentRunner)1 InitializationError (org.junit.runners.model.InitializationError)1