use of junit.framework.Test in project tomee by apache.
the class NumberedTestCase method run.
protected void run(final TestResult result, final Method testMethod) {
final Test test = createTest(testMethod);
result.startTest(test);
final Protectable p = new Protectable() {
public void protect() throws Throwable {
runTestMethod(testMethod);
}
};
// System.out.println(">>" + NumberedTestCase.class.getName() + "> started: " + testMethod.toGenericString());
result.runProtected(test, p);
result.endTest(test);
// System.out.println(">>" + NumberedTestCase.class.getName() + "> done: " + testMethod.toGenericString());
}
use of junit.framework.Test in project ignite by apache.
the class IgniteTestSuite method addTestMethod.
/**
* Add test method.
*
* @param m Test method.
* @param names Test name list.
* @param theClass Test class.
* @param clsIgnore Class ignore descriptor (if any).
* @return Result.
*/
private AddResult addTestMethod(Method m, List<String> names, Class<?> theClass, @Nullable IgnoreDescriptor clsIgnore) {
String name = m.getName();
if (names.contains(name))
return new AddResult(false, null);
if (!isPublicTestMethod(m)) {
if (isTestMethod(m))
addTest(warning("Test method isn't public: " + m.getName() + "(" + theClass.getCanonicalName() + ")"));
return new AddResult(false, null);
}
names.add(name);
IgnoreDescriptor ignore = IgnoreDescriptor.forMethod(theClass, m);
if (ignore == null)
ignore = clsIgnore;
if (ignoredOnly) {
if (ignore != null) {
Test test = createTest(theClass, name);
if (ignore.forceFailure()) {
if (test instanceof GridAbstractTest)
((GridAbstractTest) test).forceFailure(ignore.reason());
else
test = new ForcedFailure(name, ignore.reason());
}
addTest(test);
return new AddResult(true, test);
}
} else {
if (ignore == null) {
Test test = createTest(theClass, name);
addTest(test);
return new AddResult(true, test);
}
}
return new AddResult(false, null);
}
use of junit.framework.Test in project platform_frameworks_base by android.
the class BaseTestRunner method getTest.
/**
* Returns the Test corresponding to the given suite. This is
* a template method, subclasses override runFailed(), clearStatus().
*/
public Test getTest(String suiteClassName) {
if (suiteClassName.length() <= 0) {
clearStatus();
return null;
}
Class<?> testClass = null;
try {
testClass = loadSuiteClass(suiteClassName);
} catch (ClassNotFoundException e) {
String clazz = e.getMessage();
if (clazz == null)
clazz = suiteClassName;
runFailed("Class not found \"" + clazz + "\"");
return null;
} catch (Exception e) {
runFailed("Error: " + e.toString());
return null;
}
Method suiteMethod = null;
try {
suiteMethod = testClass.getMethod(SUITE_METHODNAME, new Class[0]);
} catch (Exception e) {
// try to extract a test suite automatically
clearStatus();
return new TestSuite(testClass);
}
if (!Modifier.isStatic(suiteMethod.getModifiers())) {
runFailed("Suite() method must be static");
return null;
}
Test test = null;
try {
// static method
test = (Test) suiteMethod.invoke(null, (Object[]) new Class[0]);
if (test == null)
return test;
} catch (InvocationTargetException e) {
runFailed("Failed to invoke suite():" + e.getTargetException().toString());
return null;
} catch (IllegalAccessException e) {
runFailed("Failed to invoke suite():" + e.toString());
return null;
}
clearStatus();
return test;
}
use of junit.framework.Test in project platform_frameworks_base by android.
the class TestRunner method runSingleMethod.
protected TestResult runSingleMethod(String testCase, String method, boolean wait) throws Exception {
Class<? extends TestCase> testClass = loadSuiteClass(testCase).asSubclass(TestCase.class);
Test test = TestSuite.createTest(testClass, method);
return doRun(test, wait);
}
use of junit.framework.Test in project platform_frameworks_base by android.
the class TestCaseUtil method getTestCaseNames.
@SuppressWarnings("unchecked")
public static List<String> getTestCaseNames(Test test, boolean flatten) {
List<Test> tests = (List<Test>) getTests(test, flatten);
List<String> testCaseNames = Lists.newArrayList();
for (Test aTest : tests) {
testCaseNames.add(getTestName(aTest));
}
return testCaseNames;
}
Aggregations