Pavel Voronin
Pavel Voronin

Reputation: 13985

How to make DAL integration tests less brittle?

First. We do not use ORM. And won't use it in near future. (it's not my decision).

We create stored procedures for multiple read/write cases.
Most of the reading SPs are for populating DTOs which are sent to client.

Each DAL method usually calls single SP. Integration test consists of running insert script, then initialization of expectations according to the script, calling method and then checking returned result. I.e. standard AAA pattern.

However, even small DB schema refactoring usually breaks about a hundred of tests. Prepare are the cause: whereas DTO usually needs a subset of columns. Insert requires all of them. Thus every ыскшзе that touches refactored table breaks.

I consider correcting bunch of the scripts every time after refactoring a kind of monkey job. Looking for ways of improving tests robustness.

Upvotes: 2

Views: 135

Answers (1)

Schwarzie2478
Schwarzie2478

Reputation: 2276

You could try to write generalized functions that prepare one table and use this always instead of repeating the prepare statements across your tests.

Also you could look into T4 template with interaction to the database to generate the prepare statements before compiling the tests.

Generate from T4

Upvotes: 1

Related Questions