Comments (9)
Other ways you can address this is with Dev Containers or separate Local DB instances. But using this library in those cases has diminishing returns of course.
from respawn.
I've a similar use case for Respawn, although the setup seems to be a bit more involved than yours @sergey-bulavskiy .
I create an inmemory pool of databases, that i also manage in a separate ms sql server db(TestManagementDb). Each test run creates its own set of up to 16 databases. Each time, a test needs a database, i ask my pool for an instance. Each instance knows if there is a corresponding db already created(raw sql), whether migrations(EF Core) have been run on it and whether it has been seeded with default data(EF Core).
If anything of that is still missing, i'll fix that before returning the database as EF Core dbcontext to my test. Then i run my test logic as usual and then dispose it via IAsyncDisposable, which in turn uses Respawn to clean up the data in the database and also update its state in my TestManagementDb until finally i return the database back to the pool.
Then the next test can fetch an instance from the pool. I also use Semaphore slim here.
This approach is incredibly fast, provided you can figure out the locking around the pool and how to deal with failing and cancelled tests. In my case, when all tests are done, i drop all of my 16 databases and remove the corresponding entries from my TestManagementDb aswell.
from respawn.
Hello, @Insire! Thanks for you experience, can you please clarify a couple of moments? What test framework are you using? Are your tests all in one project? I was trying to achieve concurrency via semaphore slim and database pool via xunit fixtures but failed miserably because of xunit tricky parallel execution of the tests, and xunit fixtures being project-wide at maximum. To correctly support pool for multiple projects we'd need to use Assembly-level fixture which is not supported yet.
I am using x-unit with https://github.com/JDCain/Xunit.Extensions.AssemblyFixture which does add the assembly level fixture you mentioned.
I have multple projects
- unit tests (no database involved here)
- integration tests (the majority of our tests use ms sql server as database here)
- performance tests (a form of integration test)
- smoke tests (a form of integration test)
- bdd tests (a form of integration test)
- ui tests (a form of integration test)
- bdd-ui tests (a form of integration test)
from respawn.
you can stop xunit running things in parallel by putting a collection attribute on the test class [Collection("Anything with this name won't be run in parallel")]
from respawn.
@keithn so it is intended way to use Respawn, only with sequential tests execution?
from respawn.
I can't see how you'd expect tests against a single state store to work?
from respawn.
@keithn indeed, i thought that somebody faced same problems previously and managed it somehow, but i'll stick to sequential runs, thank you.
from respawn.
Hello, @Insire!
Thanks for you experience, can you please clarify a couple of moments?
What test framework are you using? Are your tests all in one project?
I was trying to achieve concurrency via semaphore slim and database pool via xunit fixtures but failed miserably because of xunit tricky parallel execution of the tests, and xunit fixtures being project-wide at maximum. To correctly support pool for multiple projects we'd need to use Assembly-level fixture which is not supported yet.
from respawn.
Thank you very much, @Insire, will have a look on this assembly fixture!
from respawn.
Related Issues (20)
- Feature: Any plans to support MondoDB HOT 1
- Issue with truncate cascade in Postgres HOT 1
- Getting Error in ResetAsync with EmptyDatabase HOT 11
- Support for MongoDB HOT 1
- Continues to truncate Table User even if its ignored. HOT 1
- When all tables ignored, error: `BeginExecuteNonQuery: CommandText property has not been initialized.` is thrown by Respawn
- Oracle error while creating respawner when include table with schema name
- DbAdapter = DbAdapter.MySql ignored HOT 5
- SqlServer - reseed error if database is case sensitivity HOT 1
- 6.0.1 Release? HOT 1
- Cannot delete rows from a temporal history table HOT 1
- Would there be reset to snapshot feature someday? HOT 9
- Respawn if there is nothing to clear at the moment doesn't work HOT 5
- Have the option to use DELETE statements for Postgres to increase performance HOT 1
- DNDocs API Explorer
- Respawn in CosmosDB HOT 1
- Update vulnerable Microsoft.Data.SqlClient dependency HOT 2
- Add ConfigureAwait(false) to async method calls, to prevent potential deadlocks in the presence of a SynchronizationContext HOT 1
- Bump SqlClient to 5.1.3 and Npgsql to 8.0.3 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from respawn.