bug #7287
Unit 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
Associated revisions
ref #7287 base test class for all unit tests which need terms being initialized
ref #7287 fixing bug
ref #7287 reverting DerivedUnitFacade test back to using tests
History
#1 Updated by Andreas Kohlbecker almost 3 years ago
- Description updated (diff)
#2 Updated by Andreas Kohlbecker almost 3 years ago
- Related to task #7288: Separate Unit and integration tests completely, added
#3 Updated by Andreas Kohlbecker almost 3 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
#4 Updated by Andreas Kohlbecker almost 3 years ago
- Description updated (diff)
#5 Updated by Andreas Kohlbecker almost 3 years ago
- Description updated (diff)
#6 Updated by Andreas Kohlbecker almost 3 years ago
- Description updated (diff)
#7 Updated by Andreas Kohlbecker almost 3 years ago
- Tags set to test
#8 Updated by Andreas Kohlbecker almost 3 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
#9 Updated by Andreas Kohlbecker almost 3 years ago
The above mentioned problems where only due to a local change in CdmTransactionalIntegrationTest
which I applied for testing!
#10 Updated by Andreas Kohlbecker almost 3 years ago
- Status changed from New to Closed
#11 Updated by Andreas Kohlbecker almost 3 years ago
- % Done changed from 0 to 100