welcome to the next section of our course event driven microservices developing and testing with c-sharp.net and in this section we are going to talk about integration testing and how that we can Leverage The Power of integration testing to test our application in and out so we have been talking about this testing pyramid all these days and we have already covered the UI testing as well as the API testing in our earlier sections of this course so before we talk about the integration tests let's first understand the disadvantage of the UI test that we have been
discussing all these days so if you remember we talked about the disadvantages of the API and the UI tests or these like the entire application stack should be up and running all the time and also the UI testing starts becoming fragile if the application keeps changing because it's all a UI and the tests are a bit slower because it has to launch the real browsers and stuff and also the Carson effect of the change of the application will only be known until the application is fully deployed in the case of the UI test as well
as for the API test which is also another pain that we always encounter and testing API should not be just one-sided since the change in the API definition is only going to be affecting the consumer side of the application rather the producer side which is nothing but the API itself will not be affected but the consuming application which is going to be consuming the API is going to be affected so testing of the API should not be just one silent we discussed about that in our earlier section and also we told that both API API
as well as the UI test will become very costly considering the application running all the time in the cloud even though you do it for the testing if you want to mimic the actual state of your application like the production state or at least close to the production State you should be running all these Services all the time and that's going to be costing you a lot of money so how do we overcome all these disadvantages of the API and the UI test in a much much sophisticated fashion that's what we'll be covering in this
integration testing so the integration test ensures that an apps component functions correctly at a level that includes applications supporting infrastructures such as database file systems Network request response pipelines and also the most important part of the integration test is it can be done between each and every component level rather the whole application infrastructure available at any given point of time like how we saw in the API as well as for the UI testing and most important part of the integration test is that if you can see our architecture that we discussed earlier you can see
that if you want to do an integration testing between the customer portal and the customer service then we can just test these two integration alone rather the whole application up and running and similarly if you wanted to test the integration between the application and its database then we can just have this particular interactions to be tested alone similarly we can just keep splitting whole infrastructure into bits and pieces and then we can test them thoroughly so that while we mix them all together in one single gigantic application we can write very minimal test over there
because the integration test is already going to cover all these aspect of the testing of application that is the power of this whole integration test well how do we achieve all these application infrastructures to be available while we test even a specific component of the application if that's your question you ask the right question well with integration test we can run the application in memory instead of running the whole application in any costly AWS or Azure compute skus or something like that because this application is going to be spinned up along with the test code
so that there won't be any application required all the time so you don't really have to deploy the application at any given point of time while your test runs it is going to spin up the application in memory you're also going to configure your in-memory database server or some other services that you really wanted to and then it is going to spin up and run all those tests and once the test execution is done it is gonna completely take down all the services or the containers running and it's gonna just cost you as less as
possible and because this is going to be integration test you're not going to be running like a UI test or or a long running process of test there it is going to be much lesser time and also the coverage is going to be much much higher so you can see that it is going to cost you much lesser than the UI as well as the API testing counterpart well as that said how do we do this integration testing well if you ask this question well in asp.net we can do this infrastructure component such as test
web host and the in-memory test server are provided or managed by the Microsoft asp.net core MVC dot testing nuget package so if we just install this particular package and few other packages you can see that we can run our whole application in the test web host rather the IIs server or any dedicated service so that is the another great potential that we can get using the asp.net and many other Technologies even in Java for spring boot there is this mock server which runs in memory you can run that and then you can test the application
the same thing can be achieved in the dotnet word using this particular nuget package that's what we'll be discussing this whole section and you will understand the potential of the integration testing in much better fashion while we discuss about them