Project

General

Profile

Actions

bug #7287

closed

Unit tests using the DefaultTermInitializer break subsequent integration tests in the suite

Added by Andreas Kohlbecker about 6 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
New
Category:
cdmlib
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Severity:
normal
Found in Version:
Tags:

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

Related to EDIT - task #7288: Separate Unit and integration tests completely,NewAndreas Müller

Actions
Related to EDIT - bug #8174: First test fails if term data is in loaded DataSetNewAndreas Müller

Actions
Actions #1

Updated by Andreas Kohlbecker about 6 years ago

  • Description updated (diff)
Actions #2

Updated by Andreas Kohlbecker about 6 years ago

  • Related to task #7288: Separate Unit and integration tests completely, added
Actions #3

Updated by Andreas Kohlbecker about 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
Actions #4

Updated by Andreas Kohlbecker about 6 years ago

  • Description updated (diff)
Actions #5

Updated by Andreas Kohlbecker about 6 years ago

  • Description updated (diff)
Actions #6

Updated by Andreas Kohlbecker about 6 years ago

  • Description updated (diff)
Actions #7

Updated by Andreas Kohlbecker about 6 years ago

  • Tags set to test
Actions #8

Updated by Andreas Kohlbecker about 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

Actions #9

Updated by Andreas Kohlbecker about 6 years ago

The above mentioned problems where only due to a local change in CdmTransactionalIntegrationTest which I applied for testing!

Actions #10

Updated by Andreas Kohlbecker about 6 years ago

  • Status changed from New to Closed
Actions #11

Updated by Andreas Kohlbecker about 6 years ago

  • % Done changed from 0 to 100
Actions #12

Updated by Andreas Müller about 3 years ago

  • Related to bug #8174: First test fails if term data is in loaded DataSet added
Actions #13

Updated by Andreas Müller about 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

Actions

Also available in: Atom PDF