FileDocCategorySizeDatePackage
UnitTestCase.javaAPI DocHibernate 3.2.52524Tue Dec 12 16:22:26 GMT 2006org.hibernate.junit

UnitTestCase

public abstract class UnitTestCase extends TestCase
A basic JUnit {@link junit.framework.TestCase} subclass for adding some Hibernate specific behavior and functionality.
author
Steve Ebersole

Fields Summary
private static final Log
log
Constructors Summary
public UnitTestCase(String string)


	   
		super( string );
	
Methods Summary
public static voidassertClassAssignability(java.lang.Class source, java.lang.Class target)

		if ( !target.isAssignableFrom( source ) ) {
			throw new AssertionFailedError(
			        "Classes were not assignment-compatible : source<" + source.getName() +
			        "> target<" + target.getName() + ">"
			);
		}
	
public static voidassertElementTypeAssignability(java.util.Collection collection, java.lang.Class clazz)

		Iterator itr = collection.iterator();
		while ( itr.hasNext() ) {
			assertClassAssignability( itr.next().getClass(), clazz );
		}
	
public java.lang.StringfullTestName()

		return this.getClass().getName() + "#" + this.getName();
	
protected voidreportSkip(java.lang.String reason, java.lang.String testDescription)

		SkipLog.LOG.warn( "*** skipping [" + fullTestName() + "] - " + testDescription + " : " + reason, new Exception()  );
	
public voidrunBare()
runBare overridden in order to apply FailureExpected validations as well as start/complete logging

throws
Throwable

		final boolean doValidate = getName().endsWith( "FailureExpected" ) && Boolean.getBoolean( "hibernate.test.validatefailureexpected" );
		try {
			log.info( "Starting test [" + fullTestName() + "]" );
			super.runBare();
			if ( doValidate ) {
				fail( "Test marked as FailureExpected, but did not fail!" );
			}
		}
		catch( Throwable t ) {
			if ( doValidate ) {
				skipExpectedFailure( t );
			}
			else {
				throw t;
			}
		}
		finally {
			log.info( "Completed test [" + fullTestName() + "]" );
		}
	
protected voidskipExpectedFailure(java.lang.Throwable error)

		reportSkip( "ignoring *FailuredExpected methods", "Failed with: " + error.toString() );