use of junit.framework.Test in project tomee by apache.
the class FilteredTestSuite method filter.
public static List<Test> filter(final List<Test> tests) {
final String itest = System.getProperty("itest");
if (itest == null) {
return tests;
}
final ArrayList<Test> filtered = new ArrayList<Test>();
for (final Test test : tests) {
final String simpleName = test.getClass().getSimpleName();
if (simpleName.matches(itest)) {
filtered.add(test);
}
}
return filtered;
}
use of junit.framework.Test in project tomee by apache.
the class TestSuite method run.
/**
* Runs the tests and collects their result in a TestResult.
*/
public void run(final TestResult result) {
try {
final List<Test> tests = getTests();
if (tests.size() == 0)
return;
setUp();
try {
for (final Test test : tests) {
if (result.shouldStop())
break;
test.run(result);
}
} finally {
tearDown();
}
} catch (final Exception e) {
result.addError(this, e);
}
}
use of junit.framework.Test in project junit4 by junit-team.
the class SuiteMethod method testFromSuiteMethod.
public static Test testFromSuiteMethod(Class<?> klass) throws Throwable {
Method suiteMethod = null;
Test suite = null;
try {
suiteMethod = klass.getMethod("suite");
if (!Modifier.isStatic(suiteMethod.getModifiers())) {
throw new Exception(klass.getName() + ".suite() must be static");
}
// static method
suite = (Test) suiteMethod.invoke(null);
} catch (InvocationTargetException e) {
throw e.getCause();
}
return suite;
}
use of junit.framework.Test in project junit4 by junit-team.
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 junit4 by junit-team.
the class TestRunner method start.
/**
* Starts a test run. Analyzes the command line arguments and runs the given
* test suite.
*/
public TestResult start(String[] args) throws Exception {
String testCase = "";
String method = "";
boolean wait = false;
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-wait")) {
wait = true;
} else if (args[i].equals("-c")) {
testCase = extractClassName(args[++i]);
} else if (args[i].equals("-m")) {
String arg = args[++i];
int lastIndex = arg.lastIndexOf('.');
testCase = arg.substring(0, lastIndex);
method = arg.substring(lastIndex + 1);
} else if (args[i].equals("-v")) {
System.err.println("JUnit " + Version.id() + " by Kent Beck and Erich Gamma");
} else {
testCase = args[i];
}
}
if (testCase.equals("")) {
throw new Exception("Usage: TestRunner [-wait] testCaseName, where name is the name of the TestCase class");
}
try {
if (!method.equals("")) {
return runSingleMethod(testCase, method, wait);
}
Test suite = getTest(testCase);
return doRun(suite, wait);
} catch (Exception e) {
throw new Exception("Could not create and run test suite: " + e);
}
}
Aggregations