bug #7287
closedUnit tests using the DefaultTermInitializer break subsequent integration tests in the suite
100%
Description
Here we make the distinction between Unit and integration test by the fact that integration tests are sub classing CdmTransactionalIntegrationTest
.
A couple of unit test are making use of term, so the terms need to be initialized. This is done in theses tests by ca method like:
@BeforeClass
public static void setUpBeforeClass() throws Exception {
DefaultTermInitializer initializer = new DefaultTermInitializer();
initializer.initialize();
}
This approach is highly problematic:
If an integration test has run before the TestingTermInitializer
has already initialized the terms. Calling the initialize()
method of the DefaultTermInitializer will reset and override all terms. This breaks subsequent Integration tests since the TestingTermInitializer
is only run once per suite.
An interim solution which is not 100% reliable is to check in the setUpBeforeClass()
method if the terms already have been loaded. This method should be in a base class for all tests that use the DefaultTermInitializer.
As a long term task we should separate Unit and integration tests completely, see #7288
Additional tasks:
- revert
DerivedUnitFacadeCacheStrategyInjectionTest
,DerivedUnitFacadeCacheStrategyTest
,DerivedUnitFacadeFieldUnitCacheStrategyTest
to unit tests, see commented @BeforeClass
Related issues
Updated by Andreas Kohlbecker over 6 years ago
- Related to task #7288: Separate Unit and integration tests completely, added
Updated by Andreas Kohlbecker over 6 years ago
affected test class files (without cdmlib-model, model has no integration tests!):
cdmlib-ext/src/test/java/eu/etaxonomy/cdm/ext/ipni/IpniServiceTest.java cdmlib-ext/src/test/java/eu/etaxonomy/cdm/ext/geo/EuroPlusMedCondensedDistributionComposerTest.java cdmlib-ext/src/test/java/eu/etaxonomy/cdm/ext/geo/FloraCubaCondensedDistributionComposerTest.java cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/facade/DerivedUnitFacadeCacheStrategyInjectionTest.java cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/facade/DerivedUnitFacadeCacheStrategyTest.java cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/facade/DerivedUnitFacadeFieldUnitCacheStrategyTest.java cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/DistributionNodeByAreaLabelComparatorTest.java
Updated by Andreas Kohlbecker over 6 years ago
After using the new unit test base class TermTest for all test which need the terms to be initialized another strange symptom pops up.
... test in cdmlib-persistence are failing now.
The analysis of the cause for this problem reveals that the tests in cdmlib-persistence are failing if they are preceeded by the tests in cdmlib test:
mvn test -pl cdmlib-test,cdmlib-persistence
==> ALL TEST FAIL (Tests run: 436, Failures: 0, Errors: 235, Skipped: 7)
Exception: Could not obtain transaction-synchronized Session for current thread
mvn test -pl cdmlib-persistence
==> SUCCESS
in cdmlib-test there is only one test anyway. But even after disabling this test by annotating the class with @Ignore
:
mvn test -pl cdmlib-test,cdmlib-persistence
===> Still ALL TEST ARE FAILING even if no tests are running
Updated by Andreas Kohlbecker over 6 years ago
The above mentioned problems where only due to a local change in CdmTransactionalIntegrationTest
which I applied for testing!
Updated by Andreas Kohlbecker over 6 years ago
- Status changed from New to Closed
Updated by Andreas Müller over 3 years ago
- Related to bug #8174: First test fails if term data is in loaded DataSet added
Updated by Andreas Müller over 3 years ago
Andreas Kohlbecker wrote:
After using the new unit test base class TermTest for all test which need the terms to be initialized another strange symptom pops up.
... test in cdmlib-persistence are failing now.
The analysis of the cause for this problem reveals that the tests in cdmlib-persistence are failing if they are preceeded by the tests in cdmlib test:
mvn test -pl cdmlib-test,cdmlib-persistence==> ALL TEST FAIL (Tests run: 436, Failures: 0, Errors: 235, Skipped: 7)
Exception: Could not obtain transaction-synchronized Session for current thread
mvn test -pl cdmlib-persistence==> SUCCESS
in cdmlib-test there is only one test anyway. But even after disabling this test by annotating the class with
@Ignore
:mvn test -pl cdmlib-test,cdmlib-persistence===> Still ALL TEST ARE FAILING even if no tests are running
This could be related to #8174