- 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.|