use of junit.framework.Test in project android_frameworks_base by ResurrectionRemix.
the class InstrumentationTestRunnerTest method testMultipleTestClass.
public void testMultipleTestClass() throws Exception {
String classArg = PlaceHolderTest.class.getName() + "," + PlaceHolderTest2.class.getName();
mInstrumentationTestRunner.onCreate(createBundle(InstrumentationTestRunner.ARGUMENT_TEST_CLASS, classArg));
Test test = mStubAndroidTestRunner.getTest();
assertContentsInOrder(ListTestCaseNames.getTestNames((TestSuite) test), new TestDescriptor(PlaceHolderTest.class.getName(), "testPlaceHolder"), new TestDescriptor(PlaceHolderTest2.class.getName(), "testPlaceHolder2"));
}
use of junit.framework.Test in project android_frameworks_base by ResurrectionRemix.
the class TestCaseUtil method getTests.
private static List<? extends Test> getTests(Test test, boolean flatten, Set<Class<?>> seen) {
List<Test> testCases = Lists.newArrayList();
if (test != null) {
Test workingTest = null;
/*
* If we want to run a single TestCase method only, we must not
* invoke the suite() method, because we will run all test methods
* of the class then.
*/
if (test instanceof TestCase && ((TestCase) test).getName() == null) {
workingTest = invokeSuiteMethodIfPossible(test.getClass(), seen);
}
if (workingTest == null) {
workingTest = test;
}
if (workingTest instanceof TestSuite) {
TestSuite testSuite = (TestSuite) workingTest;
Enumeration enumeration = testSuite.tests();
while (enumeration.hasMoreElements()) {
Test childTest = (Test) enumeration.nextElement();
if (flatten) {
testCases.addAll(getTests(childTest, flatten, seen));
} else {
testCases.add(childTest);
}
}
} else {
testCases.add(workingTest);
}
}
return testCases;
}
use of junit.framework.Test in project android_frameworks_base by ResurrectionRemix.
the class TestCaseUtil method getTestAtIndex.
public static Test getTestAtIndex(TestSuite testSuite, int position) {
int index = 0;
Enumeration enumeration = testSuite.tests();
while (enumeration.hasMoreElements()) {
Test test = (Test) enumeration.nextElement();
if (index == position) {
return test;
}
index++;
}
return null;
}
use of junit.framework.Test 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.Test 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;
}
Aggregations