oasp / oasp4j

The Open Application Standard Platform for Java
Apache License 2.0
60 stars 303 forks source link

Database initialization for testing #216

Open Max-Goebel opened 9 years ago

Max-Goebel commented 9 years ago

How will we initialize database for testing? Which data format will we use to represent the data used to this initialization?

All solutions except solution 1 have to deal with the problem that data changes must be undone before the next test execution starts. For solution 2, DB-Unit provides tools to do this. For solution 3 and 4 the following alternatives exist:

The purpose of this ticket is to clear these questions:

anmaso commented 9 years ago

Since a batch functionality is considered also to be part of OASP, could it be also an alternative to do this initialization? or will it be overkill? kind of eating our own dog food :-)

amarinso commented 9 years ago

Sorry for last comment author, I didn't realized I was logged in github with other user.

Max-Goebel commented 9 years ago

Using the batch layer for initializing the database would be one variant of solution 4 (CRUD-functions). As we have on each layer CRUD-functionalities, we could use each layer for database initialization. But we should decide if we generally prefer the data access layer, logic layer, service layer or batch layer. But the higher the layer, the lower the performance.

hohwille commented 9 years ago

In my current project we have official DDL and master-data in src/main/resources/db/migration and testdata in src/test/resources/db/test. For tests we use H2 and the rest is done with the productive DB. The testdata is only for the common things to test and needs to be maintained in SQL with the general data-model & migration stuff. For complex test-data we combine this with additional approaches.