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);
}
}
}
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;
}
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();
}
}
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;
}
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;
}
Aggregations