vendredi 6 mars 2020

How making tests which using database faster?

i'm working on making some concepts for my company. The target is to making our Integrationtests faster. Espacially Integrationtests which are using and/or manipulating the database. I splitted our tests in 2 Categories and directories:

  • Unit-Tests
  • Integration-Tests (Here are all the testclasses which are in contact with the database)

We use Postgresql Version 9.3, Liquibase, Visualstudio and MSTest.

We have the situation that the execution of our tests is in this steps:

  1. Run Tests(Projects which are using)
  2. Create database
  3. Fill database if in the class are some methods which need the database

The problems:

  1. We fill our database before every method is running with a TestInitiliaze like this: [TestInitiliaze] public void TestInit(){ Databaseclass.FillDatabase(); }

  2. We have 450 tests which are using the database. Nearly 50 of the tests manipulating the database.

  3. The other tests using the database with reading the testdata without manipulating.

  4. The tests are mixed. That means that we have in a class tests which are manipulating the data and some which only read the data.

Target: Making this tests faster. I had a concept which is not working in our project. Using Database-Snapshots. My idea:

  1. Run tests
  2. Create database
  3. FillDatabase
  4. Takesnapshot of database
  5. [TestInitiliaze] public void testinitiliaze(){ DatabaseClass.revertToSnapshot() }
    1. Or ClassInitiliaze: DatabaseClass.revertToSnapshot()

I try to make one more concept. But it is also not working with our versions of Postgresql. Nested transactions.

Have somebody other alternatives which are working?

Best regards HaGem

Aucun commentaire:

Enregistrer un commentaire