4 ms·
How do you unit test your sql? At least with orms, the data access is tested implicitly via business logic unit tests.
by tra3 4y ago
How do you unit test your sql? At least with orms, the data access is tested implicitly via business logic unit tests.
- noisem4ker 4y agoAt the repository (data access) application layer. For a query (e.g. loading an entity): - Arrange: test database loaded with fixtures - Act: execute repository method - Assert: returned data corresponds to fixture For updating queries: additionally assert the new database state. Repository tests shouldn't care nor know whether the methods under test internally execute raw SQL or use ORM methods. This allows freely switching and mixing the two.