Search in sources :

Example 66 with TestSuite

use of junit.framework.TestSuite in project intellij-community by JetBrains.

the class TestAllInPackage2 method skipSubtests.

private static void skipSubtests(Set allNames, Test test, String currentSuiteName) {
    if (test instanceof TestSuite) {
        for (int idx = 0; idx < ((TestSuite) test).testCount(); idx++) {
            Test childTest = ((TestSuite) test).testAt(idx);
            final String testName = childTest.toString();
            if (!currentSuiteName.equals(testName)) {
                allNames.remove(testName);
            }
            skipSubtests(allNames, childTest, currentSuiteName);
        }
    }
}
Also used : TestSuite(junit.framework.TestSuite) Test(junit.framework.Test)

Example 67 with TestSuite

use of junit.framework.TestSuite in project intellij-community by JetBrains.

the class TestRunnerUtil method createClassOrMethodSuite.

public static Test createClassOrMethodSuite(JUnit3IdeaTestRunner runner, String suiteClassName) {
    String methodName = null;
    int index = suiteClassName.indexOf(',');
    if (index != -1) {
        methodName = suiteClassName.substring(index + 1);
        suiteClassName = suiteClassName.substring(0, index);
    }
    Class testClass = loadTestClass(runner, suiteClassName);
    if (testClass == null)
        return null;
    Test test = null;
    if (methodName == null) {
        if (test == null) {
            try {
                Method suiteMethod = testClass.getMethod(BaseTestRunner.SUITE_METHODNAME, new Class[0]);
                if (!Modifier.isStatic(suiteMethod.getModifiers())) {
                    String message = MessageFormat.format(ourBundle.getString("junit.suite.must.be.static"), new Object[] { testClass.getName() });
                    System.err.println(message);
                    //runFailed(message);
                    return null;
                }
                try {
                    //noinspection SSBasedInspection
                    // static method 
                    test = (Test) suiteMethod.invoke(null, new Class[0]);
                    if (test == null) {
                        return new FailedTestCase(testClass, BaseTestRunner.SUITE_METHODNAME, MessageFormat.format(ourBundle.getString("junit.failed.to.invoke.suite"), new Object[] { "method " + suiteClassName + ".suite() evaluates to null" }), null);
                    }
                    test = new SuiteMethodWrapper(test, suiteClassName);
                } catch (final InvocationTargetException e) {
                    final String message = MessageFormat.format(ourBundle.getString("junit.failed.to.invoke.suite"), new Object[] { testClass + " " + e.getTargetException().toString() });
                    //System.err.println(message);
                    //runner.runFailed(message);
                    runner.clearStatus();
                    return new FailedTestCase(testClass, BaseTestRunner.SUITE_METHODNAME, message, e);
                } catch (IllegalAccessException e) {
                    String message = MessageFormat.format(ourBundle.getString("junit.failed.to.invoke.suite"), new Object[] { testClass + " " + e.toString() });
                    //runner.runFailed(message);
                    return new FailedTestCase(testClass, BaseTestRunner.SUITE_METHODNAME, message, e);
                }
            } catch (Throwable e) {
                // try to extract a test suite automatically
                runner.clearStatus();
                test = new TestSuite(testClass);
            }
        }
    } else {
        test = createMethodSuite(runner, testClass, methodName);
    }
    return test;
}
Also used : TestSuite(junit.framework.TestSuite) Test(junit.framework.Test) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 68 with TestSuite

use of junit.framework.TestSuite 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 69 with TestSuite

use of junit.framework.TestSuite in project ACS by ACS-Community.

the class SamplingSystemUIJUnitTest method suite.

public static Test suite() {
    TestSuite suite = new TestSuite("Test for ACS Sampling System UI");
    suite.addTestSuite(AcsInformationTest.class);
    suite.addTestSuite(ComponentsManagerTest.class);
    suite.addTestSuite(SampDetailTest.class);
    suite.addTestSuite(SamplingManagerTest.class);
    suite.addTestSuite(ThreadCommunicatorTest.class);
    suite.addTestSuite(DataItemTest.class);
    return suite;
}
Also used : TestSuite(junit.framework.TestSuite)

Example 70 with TestSuite

use of junit.framework.TestSuite in project android_frameworks_base by DirtyUnicorns.

the class DownloadManagerTestRunner method getAllTests.

@Override
public TestSuite getAllTests() {
    TestSuite suite = new InstrumentationTestSuite(this);
    suite.addTestSuite(DownloadManagerTestApp.class);
    return suite;
}
Also used : TestSuite(junit.framework.TestSuite) InstrumentationTestSuite(android.test.InstrumentationTestSuite) InstrumentationTestSuite(android.test.InstrumentationTestSuite)

Aggregations

TestSuite (junit.framework.TestSuite)1380 InstrumentationTestSuite (android.test.InstrumentationTestSuite)100 Test (junit.framework.Test)63 GwtIncompatible (com.google.common.annotations.GwtIncompatible)54 JUnit4TestAdapter (junit.framework.JUnit4TestAdapter)50 TestCase (junit.framework.TestCase)48 Entry (java.util.Map.Entry)36 TestResult (junit.framework.TestResult)33 List (java.util.List)28 Set (java.util.Set)27 TestProjectSetup (org.eclipse.wst.jsdt.web.ui.tests.internal.TestProjectSetup)27 ArrayList (java.util.ArrayList)25 ListTestSuiteBuilder (com.google.common.collect.testing.ListTestSuiteBuilder)24 TestStringSetGenerator (com.google.common.collect.testing.TestStringSetGenerator)24 Map (java.util.Map)19 File (java.io.File)16 Method (java.lang.reflect.Method)16 HashSet (java.util.HashSet)13 Helpers.mapEntry (com.google.common.collect.testing.Helpers.mapEntry)12 TestStringMultisetGenerator (com.google.common.collect.testing.google.TestStringMultisetGenerator)12