mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-28 14:59:12 +00:00
git-svn-id: https://svn.jboss.org/repos/hibernate/core/branches/Branch_3_2@11766 1b8cb986-b30d-0410-93ca-fae66ebed9b2
43 lines
1.0 KiB
Java
43 lines
1.0 KiB
Java
package org.hibernate.junit;
|
|
|
|
import java.util.Enumeration;
|
|
|
|
import junit.framework.TestSuite;
|
|
import junit.framework.Test;
|
|
|
|
/**
|
|
* Handles walking a TestSuite hierarchy for recognition of individual tests.
|
|
*
|
|
* @author Steve Ebersole
|
|
*/
|
|
public class TestSuiteVisitor {
|
|
|
|
private final TestSuiteVisitor.Handler handler;
|
|
|
|
public TestSuiteVisitor(TestSuiteVisitor.Handler handler) {
|
|
this.handler = handler;
|
|
}
|
|
|
|
public void visit(TestSuite testSuite) {
|
|
handler.startingTestSuite( testSuite );
|
|
Enumeration tests = testSuite.tests();
|
|
while ( tests.hasMoreElements() ) {
|
|
Test test = ( Test ) tests.nextElement();
|
|
if ( test instanceof TestSuite ) {
|
|
visit( ( TestSuite ) test );
|
|
}
|
|
else {
|
|
handler.handleTestCase( test );
|
|
}
|
|
}
|
|
handler.completedTestSuite( testSuite );
|
|
}
|
|
|
|
public static interface Handler {
|
|
public void handleTestCase(Test test);
|
|
public void startingTestSuite(TestSuite suite);
|
|
public void completedTestSuite(TestSuite suite);
|
|
}
|
|
|
|
}
|