Search in sources :

Example 1 with SuiteMethod

use of org.junit.internal.runners.SuiteMethod 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)

Aggregations

Method (java.lang.reflect.Method)1 Test (junit.framework.Test)1 TestSuite (junit.framework.TestSuite)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 Suite (org.junit.runners.Suite)1