Project

General

Profile

bug #8174

First test fails if term data is in loaded DataSet

Added by Andreas Müller over 2 years ago. Updated 3 months ago.

Status:
New
Priority:
Priority14
Category:
cdmlib
Target version:
Start date:
03/11/2019
Due date:
% Done:

0%

Severity:
normal
Found in Version:
Tags:

Description

This is because the unitils/dbunit JpaModul starts the application context only during

 beforeTestMethod()

Also the test method dataset are injected during this phase but they are inserted by the DbUnit (or database) modul which comes first in the default unitils modul order.
The problem is that JpaModul creates the application context only during the first call of this method. This includes calling the TestingTermInitializer which calls a CleanInsert of all terms via calling a CleanInsertLoadingStrategy inside. This removes the before loaded terms and term collections from the dataset.

There are different solution:

  1. simply change unitils modul order in unitils.properties
  2. adapt JpaModul so that it creates the context during "beforeTestClass()"
  3. remove TestingTermInitializer and always load terms only via dataset for each class (advantage, dataset is more predictable as each testclass starts with the same data)

Additionally we could split the term test datasets into core terms and additional terms which include e.g. TDWG data, additional languages, audited terms, ... This will increase loading time and makes the dataset(s) easier to maintain.


Related issues

Related to Edit - bug #7287: Unit tests using the DefaultTermInitializer break subsequent integration tests in the suite Closed 02/21/2018

History

#1 Updated by Andreas Müller over 2 years ago

This is the order how events are handled in unitils:

  • [Unitils] beforeTestClass - TestClass1
  • [Test] testBeforeClass - TestClass1 (not for JUnit3)
  • [Unitils] afterCreateTestObject - TestClass1
  • [Unitils] beforeTestSetUp - TestClass1
  • [Test] testSetUp - TestClass1
  • [Unitils] beforeTestMethod - TestClass1 - test1
  • [Test] testMethod - TestClass1 - test1
  • [Unitils] afterTestMethod - TestClass1 - test1
  • [Test] testTearDown - TestClass1
  • [Unitils] afterTestTearDown - TestClass1
  • [Unitils] afterCreateTestObject - TestClass1 (not for TestNG)
  • [Unitils] beforeTestSetUp - TestClass1
  • [Test] testSetUp - TestClass1
  • [Unitils] beforeTestMethod - TestClass1 - test2
  • [Test] testMethod - TestClass1 - test2
  • [Unitils] afterTestMethod - TestClass1 - test2
  • [Test] testTearDown - TestClass1
  • [Unitils] afterTestTearDown - TestClass1
  • [Test] testAfterClass - TestClass1 (not for JUnit3)

#2 Updated by Andreas Müller over 2 years ago

  • Target version changed from Release 5.6 to Release 5.7

#3 Updated by Andreas Müller about 2 years ago

  • Target version changed from Release 5.7 to Release 5.8

#4 Updated by Andreas Müller about 2 years ago

  • Target version changed from Release 5.8 to Release 5.10

#5 Updated by Andreas Müller almost 2 years ago

  • Target version changed from Release 5.10 to Release 5.11

#6 Updated by Andreas Müller over 1 year ago

  • Target version changed from Release 5.11 to Release 5.12

#7 Updated by Andreas Müller over 1 year ago

  • Priority changed from Highest to Priority14
  • Target version changed from Release 5.12 to Release 5.13

#8 Updated by Andreas Müller over 1 year ago

  • Target version changed from Release 5.13 to Release 5.14

#9 Updated by Andreas Kohlbecker over 1 year ago

  • Description updated (diff)

I think we should go for option 3) that is to remove TestingTermInitializer and to rely only on the Datasets being loaded as this strategy promises higher predictablity

#10 Updated by Andreas Müller over 1 year ago

  • Target version changed from Release 5.14 to Release 5.15

#11 Updated by Andreas Müller about 1 year ago

  • Target version changed from Release 5.15 to Release 5.18

#12 Updated by Andreas Müller 8 months ago

  • Target version changed from Release 5.18 to Release 5.19

#13 Updated by Andreas Kohlbecker 8 months ago

Andreas Kohlbecker wrote:

I think we should go for option 3) that is to remove TestingTermInitializer and to rely only on the Datasets being loaded as this strategy promises higher predictablity

How does this affect the test performance? The TestingTermInitializer is currently only run once per test suite. Loading the terms as data-set would mean that the terms are loaded at least for each test class. We should measure the time needed for loading the test terms in order to estimate the total overhead.

Another option would be to use use an different test tool than db-unit. There should be frameworks that guarantee that the test data base is reverted to it's original state after each test method.

#14 Updated by Andreas Müller 6 months ago

  • Target version changed from Release 5.19 to Release 5.21

#15 Updated by Andreas Müller 6 months ago

  • Related to bug #7287: Unit tests using the DefaultTermInitializer break subsequent integration tests in the suite added

#16 Updated by Andreas Müller 5 months ago

  • Target version changed from Release 5.21 to Release 5.22

#17 Updated by Andreas Müller 3 months ago

  • Target version changed from Release 5.22 to Release 5.27

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 40 MB)