mardi 9 février 2021

SqLite in memory shared state across unit tests

In all my unit tests I create Sqlite in memory database in TestInitialize like that:

new SQLiteConnection("Data Source=:memory:;Version=3;New=True;"); I'm creating all tables and loading the same data across all tests during TestInitialize as well.

Then in the tests I'm doing some commands and queries on the database.

When I'm running test one by one everything works fine. When I'm launching all tests together, some tests fails. Tests seams to run one by one, not all at the same time.

I try to release the connection in TestCleanup but nothing seams to works.

Connexion.Close();

Connexion.Dispose();

GC.SuppressFinalize(Connexion);

GC.Collect();

I also tried to drop all tables in TestCleanup, but not working.

Any clue? Regards,

Aucun commentaire:

Enregistrer un commentaire