Refactor and improve integration test fixtures.#360
Merged
Conversation
Collaborator
Author
|
Note to self: The connection to the database fails. It happens randomly for a given project, usually 2 of them succeed completely and 1 one of them fails (and they shift randomly). I suspect now that we're creating DbContext for each test separately, we face connection pool exhaustion perhaps? Btw, locally there is no issue at all; neither running from Test Explorer, nor through cli, nor through Docker. It has to do something with the environment in CI. |
ardalis
approved these changes
Aug 7, 2023
Owner
ardalis
left a comment
There was a problem hiding this comment.
Not loving having to add 2 lines to every test for the dbContext but I get it...
This was referenced Jul 21, 2025
This was referenced Jul 31, 2025
This was referenced Dec 20, 2025
Open
Bump Ardalis.Specification.EntityFrameworkCore from 7.0.0 to 9.3.1
gshabbirdeveloper/MyEshopWebApp#4
Open
This was referenced Dec 29, 2025
Closed
This was referenced Jan 8, 2026
Open
This was referenced Jan 23, 2026
This was referenced Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #359. More details on the related issue.
This PR contains the following improvements.
DatabaseFixture. We'll create a unique database per each instance, and we'll delete the database on disposal.HasData).DbContext, instead, we create a separate context for each test. This will lead to more reliable tests (especially while testingIncludefeatures).ReadCollectionthat is utilized for all repository read actions.ClassFixtureinstead.EF CoreandEF6are consistent now.