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

The following examples show how to use junit.framework.TestSuite#setName() . 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: TestSuiteBuilder.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Scans *Test.class files under org.kuali for matches against the given strategies.
 * 
 * @param classCriteria strategy for whether to include a given TestCase in the suite. If included, a test class acts like a
 *        sub-suite to include all its test methods. Classes not included may still include methods individually.
 * @param methodCriteria strategy for whether to include a given test method in the suite, if the whole class was not included.
 * @return a TestSuite containing the specified tests
 * @throws java.io.IOException if the directory containing this class file cannot be scanned for other test class files
 * @throws Exception if either of the given criteria throw it
 */
public static TestSuite build(ClassCriteria classCriteria, MethodCriteria methodCriteria) throws Exception {
    TestSuite suite = new TestSuite();
    for (Class<? extends TestCase> t : constructTestClasses(scanTestClassNames(getTestRootPackageDir()))) {
        if (t.isAnnotationPresent(Exclude.class)) {
            continue; // don't consider any methods of this test either
        }
        if (classCriteria.includes(t)) {
            suite.addTestSuite(t);
        }
        else {
            for (Method m : t.getMethods()) {
                if (isTestMethod(m) && methodCriteria.includes(m)) {
                    suite.addTest(TestSuite.createTest(t, m.getName()));
                }
            }
        }
    }
    suite.setName(getDefaultName());
    return suite;
}
 
Example 2
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 3
Source File: ModelTestSuite.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public TestSuite makeTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName(this.getSuiteName());
    for (Test tst: this.getTestList()) {
        prepareTest(tst);
        suite.addTest(tst);
    }

    return suite;
}