Project

General

Profile

bug #8174

First test fails if term data is in loaded DataSet

Added by Andreas Müller 13 days ago. Updated 13 days ago.

Status:
New
Priority:
Highest
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:

  • simply chnage unitils modul order in unitils.properties
  • adapt JpaModul so that it creates the context during "beforeTestClass()"
  • 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.

History

#1 Updated by Andreas Müller 13 days 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)

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 40 MB)