Version 6

    This page is out of date: content has moved there.

    Hibernate Core uses JUnit 3.8 for writing unit and integration tests.  However, instead of extending your tests from junit.framework.TestCase directly you can utilize some of the test base classes publised in the hibernate-testing module. One of this classes is HibernateTestCase which serves as  base class for org.hibernate.test.annotations.TestCase (Hibernate Annotations), org.hibernate.ejb.test.TestCase (EntityManager)  and org.hibernate.search.test.SearchTestCase (Hibernate Search). The  special feature of HibernateTestCase is the ability to annotate a  single test or a whole test class with one of the following  annotations:

    • FailureExpected - allows to skip a single test or all test of a class, because test failures are expected. The test will acutally run, but not lead to an error report. In fact if a test is marked with @FailureExpected and the test actually succeed an error occurs. As a parameters to this annotation a jira key is required.
    • RequiresDialect - tests methods/classes annotated with @RequiresDialect will only run if the current Dialect is matching the one specified on as annotation parameter. You can also specify a comment and/or jira key explaining why this test requires a certain dialect
    • RequiresDialectFeature - tests methods/classes annotated with @RequiresDialectFeature will only run if the current Dialect offers the specified feature. Examples for this features are SupportsSequences, SupportsExpectedLobUsagePattern or SupportsIdentityColumns. You can add more feature if you need to. Have a look at DialectChecks.
    • SkipForDialect - tests methods/classes annotated with @SkipForDialect will not run if  the current Dialect is matching the one specified on as annotation  parameter. You can also specify a comment and/or jira key explaining why  this test has to be skipped for the Dialect.