Java Code Examples for junit.framework.TestSuite#countTestCases()

The following examples show how to use junit.framework.TestSuite#countTestCases() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSuiteUtilities.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private static TestSuite getTestSuite(String pkgName, boolean recurse) {

	TestSuite suite = new TestSuite();
	suite.setName("[Package] " + pkgName);
	
	// Add all TestCases contained within the specified package
	Iterator<String> iter = getClassNames(pkgName, TEST_CASE_CLASS);
	while (iter.hasNext()) {
		String name = iter.next();
		try {
			suite.addTest(new TestSuite(Class.forName(name)));
		} catch (ClassNotFoundException e) {
			System.out.println("Failed to load test case: " + name);
		}
	}
	
	// Recursively add TestSuites associated with sub-packages
	if (recurse) {
		iter = getSubPkgNames(pkgName);
		while (iter.hasNext()) {
			String subPkgName = iter.next();
			TestSuite ts = getTestSuite(subPkgName, true);
			if (ts.countTestCases() > 0) {
				suite.addTest(ts);
			}
		}
	}
	
	return suite;	
}
 
Example 2
Source File: JUnit38ClassRunner.java    From android-test with Apache License 2.0 4 votes vote down vote up
private static String createSuiteDescription(TestSuite ts) {
  int count = ts.countTestCases();
  String example = count == 0 ? "" : String.format(" [example: %s]", ts.testAt(0));
  return String.format("TestSuite with %s tests%s", count, example);
}