ASP.NET Core Integration Testing Tutorial
HTML-код
- Опубликовано: 21 ноя 2024
- 💻Get the source code: go.dotnetacade...
Learn how to write integration tests for your ASP.NET Core APIs, step by step.
Verify your controllers in real-world scenarios by bootstrapping your entire app in memory, using a real database and even deal with endpoints that require authorization.
🔥Become a .NET Cloud Developer: juliocasal.com...
🗺️Get My Free .NET Backend Developer Roadmap: juliocasal.com...
Join me on Patreon: / juliocasal
Follow me on LinkedIn: / juliocasal
Follow me on X: x.com/julioc
#csharp #aspnetcore #softwaretesting
This is exactly how we've set up integration tests with one exception. We're using "test containers" to generate a whole bunch of docker based databases. That way you can still run tests in parallel without them getting in each other's way.
Ohh, great idea! Will check it out.
Finally normal pace. Thank you.
Wow very Amazing content you produced on your RUclips channel. Really apricate your efforts
So nice of you!
Great video, thanks for the effort put into this.
My pleasure!
Thanks a gazillion. Super videi, was really helpfull 😊😊
Glad it was helpful!
Gracias por compartir Julio!
De nada!
Gracias Julio.
De nada!
Besides "Database.EnsureDeleted", I also had to add "Database.EnsureCreated"
That may be needed if your app doesn't run migrations on start, which would create the DB for you.
this video was very well made but I got stuck at the InternalsVisibleTo step, the same error still showed in the Program not being visible to the tests project
Did you use the correct project name? InternalsVisibleTo should just work.
@@juliocasal No, the only thing that worked for me was including
public partial class Program {} in the program.cs file
did you use microsoft testserver here? also is there a problem if i use moq?
Just the WebApplicationFactory. No issues with moq.
In my project, API endpoint expects JWT bearer token, This approach is not working for me, please guide me how to pass jwt token while doing integration testing.
Just prepare the database image to contain certain data, handle the token signature just as the connection string is being handled in this video, then as part of your arrange generate the token.
This is a great starting point, try to expand it to cover your needs.
What is not working?
Tried this tutorial but for some reason the Integration testing continues to use my actual Database connection instead of my In-Memory one?
There's no in-memory database.
It will be better if you add link to git repository. Much cannot be repeated. What you show is taken out of context👎
Here: www.patreon.com/posts/88196476
@@juliocasal If you share your experience here, complete it instead of starting here, and you will learn the rest from the course. This is the worst thing that exists and there is not the slightest desire to attend such courses, since it is possible that everything necessary will not be there and another course will be required, and so on. With this approach, I wish you to have as few subscribers and people willing to buy your courses as possible.
@@valeriyaleksandrovich2707 Which course? All you'll find there is the full source code.
@@juliocasal if I saw the code, I would say Thank you, but I see the cartridge and you have to pay for the connection