Replies: 4 comments 3 replies
-
hi, are you using xUnit? i can write few words later today about some tricks how I deal with that situation |
Beta Was this translation helpful? Give feedback.
-
If you want you can take a look at https://github.com/ajeckmans/ReqnrollIntegrationTests This more or less is a way more simplified version of how I typically set up tests for a web application. I do want to note that it involves some less than typical set up of reqnroll and that I have not really organized the files nicely. I just did the bare minimum to create a webapp that has a dbcontext and a test set up that spins up a test container. The reqnroll set up requires no packages other than the core reqnroll xunit package. I've found that the other DI containers get in the way and that BoDi is actually good enough for even advanced scenarios. |
Beta Was this translation helpful? Give feedback.
-
@vyruz1986 Did any of our answers help? |
Beta Was this translation helpful? Give feedback.
-
@vyruz1986 I would be interested to hear more about the comment you have made earlier
My understanding was that the method with |
Beta Was this translation helpful? Give feedback.
-
So after hearing some high-level stuff about SpecFlow for the past years, and meaning to get to know it, yesterday I decided to look into it, and quickly arrived here after learning SpecFlow is dead (all hail ReqnRoll :))
I feel like this should be a feature request, but since I'm very new to this framework I wanted to gather some input first.
What I'm trying to do is writing integration tests, mayb ReqnRoll is not the correct solution for this, if so, please elaborate.
For these integration tests I need to setup quite some dependencies (e.g. RabbitMQ, MSSQL server, Redis cache, ...)
I usually write integration tests using xUnit's
IAsyncLifetime
interface which I implement somewhere appropriate, this allows me to implment anValueTask InitializeAsync()
method which will be run at the start of the unit tests which I can then use in combination with e.g. https://dotnet.testcontainers.org/ to spin up all those 3rd party dependencies and retrieve connections strings for those instances.I then usually construct classes that need those dependencies (e.g. EF Core's
DbContext
implementation of the application I'm testing) and store them as a property in my test class so I can then use them in my test cases.Now I'm wondering how to achieve something similar with ReqnRoll, I'm aware about Hooks (which somewhat resemble xUnit's
IAsyncLifetime
). And I'm also aware of the ReqnRoll's DI system (or even 3rd party integrations like Microsoft's DI container).So exploring those options, I come to the following conclusions:
DbContext
requiresDbContextOptions<T>
to be passed from somewhere.[ScenarioDependencies]
attribute. Since https://dotnet.testcontainers.org/ only supportsasync
methods to start/stop their containers, this won't workDbContext
etc instances.I can hardly believe I'm the first trying to write integration tests, or perhaps I'm going about this completely the wrong way, so I would be greatful to hear how other people have solved this.
Beta Was this translation helpful? Give feedback.
All reactions