On Aug 8, 2005, at 1:08 PM, Steve Ebersole wrote:

The reason for this instead of just
overriding setUp()/tearDown() would be to only execute this stuff when
we actually rebuild the session fatory.

I worked on the CaveatEmptor tests and I do this using the TestSetup decorator:

    public static Test suite() {

        TestSuite suite = new TestSuite();

        suite.addTestSuite( UserTest.class );
        suite.addTestSuite( ItemTest.class );
        suite.addTestSuite( CategoryItemTest.class );
        suite.addTestSuite( AuditTest.class );
        suite.addTestSuite( NestedSetTest.class );

        return new HibernateTestSetup(suite);
    }


public class HibernateTestSetup extends junit.extensions.TestSetup {

    public HibernateTestSetup(Test test) {
        super(test);
// Enable automatic schema generation for unit testing, if not already set in configuration HibernateUtil.getConfiguration().setProperty (Environment.HBM2DDL_AUTO, "create-drop");
    }

    protected void setUp() throws Exception {
        super.setUp();
        HibernateUtil.rebuildSessionFactory();
    }

    protected void tearDown() throws Exception {
        super.tearDown();
        HibernateUtil.getSessionFactory().close();
    }

}

This setup/teardown is executed once for the suite I'm wrapping.



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to