Integration testing

Integration testing is very similar to unit testing in a way that in both types of testing we test classes by making their objects invoke their methods. But they are different in how we test classes. In case of unit testing, we don't touch other objects with which our class under test is interacting with. But in integration testing, we want to see how it all works together. We let them interact with each other.

Sometimes, everything is working fine as per the unit test but not at higher-level tests (functional test or acceptance test) where we test it on the basis of requirements by hitting the URL. So, in some cases, higher-level tests are failing and unit tests are passing so to narrow down where the problem is, integration tests are very useful. So, you can consider that the integration test stands somewhere between functional tests and unit tests. Functional testing is about testing the functional requirement while unit testing is about testing a single unit. So, an integration test is in the middle of both, it tests how these single units work together; however, it tests by testing small components from code but lets them interact with each other as well.

Some developers write integration tests and call it a unit test. Actually, integration tests just let code under the test to interact with other objects, so it can test how those classes work when they interact with system components. So, some people write integration tests if the code under test is very simple that needs to be tested while interacting with the system. However, it is not necessary to only write one unit test or integration test, you can write both if you have time.

The benefits of integration testing: