ASP.NET Integration Testing

preview_player
Показать описание
Unit tests on a Web API application can save time, but they can miss errors the occur with API itself - or report errors that aren't really there. Integration testing is the solution.

Topics include:
- The problems of manual testing
- The problems of external test scripts
- The problems of unit testing in C#
- Integration testing with the ASP.NET WebApplicationFactory
- Injecting Moq objects
- Access Program by avoiding top-level statements
Рекомендации по теме
Комментарии
Автор

Testing is one of the most important areas of software development. Any other aspects you want to know about?
And if you liked the video, click the 👍.

CodingTutorialsAreGo
Автор

Funny. Was just talking about this approach with a colleague 30 minuts ago and then you released a video about it. Thank you!

CRBarchager
Автор

Thank you so much, sir. I have to do a presentation at my workplace and your video has gave me the key of integration tests in a breeze. I'm grateful.

burakt
Автор

Hi Jesper thank you for your videos, they are really helpful!

I have some suggestions for future videos: It would be nice to hear your perspectives on Design patterns and the architecture of applications. I love to hear perspectives from people with a lot of experience, because a new developer is bombarded with all these "SOLID" Principles and weird over-engineered architectures on the internet when in my opinion these things should just be "guidelines" that you probably should use, but only if your application has the need for them.

Here is an example what the talking points in an "application architecture" video could be:
- brief history of how architectures evolved over time
- how to design a layer (e.g. Folderstructure)
- why we use different layers
- when should we add a new layer
- differences and commonalities between different architectures (monolith, onion, hexagonal, microservices)
- how to design a class
- how to design a method (This is an important topic that is not talked enough about in my opinion)
...

Examples of design patterns videos could be:
- when and why exactly should we use them
- different implementations of the pattern (more "complicated" implementation vs "simple" implementation and when to use which one) (I only ever see complicated implementation of patterns, which in my opinion could be written much simpler for a lot of applications)
- related/similar patterns and their differences

There is a lot to talk about but so little good information on the internet.
These topics are probably really dry, but I hope you consider these topics for your new videos.

Thanks!

schwammkopf
Автор

Thank you so much as a young developer. Your videos are giving me so much in depth knowledge. I will start a private project doing Intergration test for the current api I am developing.

innocentversace
Автор

Amazing!!! Another in time video I was looking for, thank you very much Jasper!!

diegomelgar
Автор

Amazing video!! This channel needs to be seen more.

sujitwarrier
Автор

Amazing video!
Thank you so much for explaining it so well

ikeuzoma
Автор

Hi Jesper, thank you for your explanation. A few things are clear to me now, however considering that this is integration testing, I would like to hear your opinion on mocking in integration tests. As I understand it, mocking a repository in an integration test goes against the essence of an integration test that is meant to test the end-to-end flow. In your example, the scope of the test only covers an http call made to the controller. It does not cover the repository and the database.

webnoel
Автор

Thanks for video. It's so curious. But I've a one concern about Mocking for integration tests. Integration tests are needed specifically to test a part and including the database. And using Mock is not correct in my opinion.

MrLedsky
Автор

Brilliant! Thanks for that valuable content.

mirekmiedziarek
Автор

Hi Jasper. Thanks. I'd like to know how to create integration tests for gRPC service.

philippelombaers
Автор

Amazing!! many thanks.. very helpful tutorial :) I wounder if (in Memory) testing data belongs to unit test or integration test?

SumayaAli-qh
Автор

hi Jesper, one question.

If your API is configured with SnakeCase naming convention to translate the request payload to PascalCase request classes and response classes with PascalCase to snake_case to as the response.

How to setup the BaseTest or the factory.CreateClient() to make the client requests made in the test fact are transform to snake case convetion?

Let's say for example:

var response = await _client.PostAsync("api/v1/auth/register", JsonContent.Create(new
{
FirstName = "john",
LastName = "doe",
// more attributes
}));

internally, what is required is that the request is transformed to

{
"first_name": "john",
"last_name": "doe"
}

diegomelgar
Автор

How can I further my knowledge on this topic. A book recommendation / documentation will be very welcome

innocentversace
Автор

hi, great video!
if i understand correctly for the integration test, you're not actually accessing the db?

would it be better to make an integration test with a db (managing test data so there's no conflict or using containers for db) in which case both the db and api calls would be tested together in the same test without needing fake data for testing the api?

also, i'm trying to understand the difference, is "mockRepository" actually a stub since it's not the subject being tested?

thank you

iamacsel
Автор

What if the api we are testing need authentication?

mohsin
Автор

You saved my day witha small detail !!!! cheers

vespuxi
Автор

Thanks but
"_client = _factory.CreateClient()" is giving the error 'The server has not been started or no web application was configured.'
Might be my API?

stevemcqueen
Автор

Well it helped a lot. But I didn't understand why we want Moq?

dvldev
visit shbcf.ru