Unit Testing vs Integration Testing

  • Unit Testing – It is the practice of testing discrete units of functionality, typically individual functions/methods, in isolation. If your test uses some external resource, like a service call or a database call, it’s not a unit test. Generally we mock objects to keep dependencies out of the  unit tests.
  • Integration Testing – It is the practice of testing how different pieces of the system work together and identify issues that arise when different modules are interacting with each other.


                              Unit Testing                             Integration Testing
This is basically the first type of testing to be carried out. This is carried out after Unit testing.
Unit testing checks if the discrete piece of code is doing what it is supposed to do. Integration testing checks if different pieces of the modules are working together.
The scope of Unit testing is narrow – it just covers the small piece of code under test. The scope of Integration testing is wide — it covers the whole application under test.
Unit tests are not dependent on code outside of the unit being tested. Integration testing is dependent on other outside systems like databases, service calls etc.
The goal of Unit testing is to test each unit separately and ensure that each unit is working as expected. The goal of Integration testing is to test combined modules together and ensure that every combined modules are working as expected.
Unit Tests are faster, since there are no external dependencies and the fact that it tests a small function/method. Integration Tests are slower than Unit Tests , since they interact with external systems and verify the overall system.

Categories: C#, Testing

5 replies

  1. I could not resist commenting. Exceptionally well written!

    Liked by 1 person

  2. Excellent documentation! and Clearly well said !!!

    Liked by 1 person

  3. One more point that can be considered in Integration Testing is, objects should not be mocked. Make sense?

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: