Unit Testing vs
Integration Testing –
What’s the difference
rockinterview.in
Confusion between Unit Testing and Integration Testing
For someone looking to start a career in software testing, you might have came
across terms such as Unit Testing and Integration Testing. You would have wondered
what is the difference between the two.
In Software Development Lifecycle, a software is developed by many developers who
work on individual modules. These modules are then integrated into a full-fledged
software. The testing specific to these modules and the integrated software is what is called
Unit and Integration Testing respectively.
rockinterview.in
What is Unit Testing?
At its core, unit testing is a type of test to check if an individual small piece of code is doing
what it is supposed to do.
A Unit Test is -
Repeatable: You can rerun the same test as many times as you want.
Consistent: Every time you run it, you get the same result.
In Memory: It has no “hard” dependencies on anything not in memory (such as file system,
databases, network)
Fast: It should take less than half a second to run a unit test.
Checking one single concern or “use case” in the system
rockinterview.in
What is Integration Testing?
Integration testing is a type of testing to check if different pieces of the modules work
together as a whole.
An Integration Test might -
Use system dependent values that change dynamically (such as DateTime.Now, or
Environment.MachineName)
Create objects of which it has little control (such as threads, random number
generators)
Reach out to external systems or local machine dependencies (from calling web
services to using local configuration files)
Test multiple things in the course of one test case (from database integrity to
configurations, to protocols, to system logic; all in one go).
rockinterview.in
Two Methods for Integration Testing
Bottom-up integration testing typically
begins with unit testing, followed by
tests of progressively higher-level
combinations of units called modules
or builds.
The top-down integration testing
begins with the highest-level modules
being tested first and progressively
lower-level modules are tested
afterwards.
Bottom-up Method Top-down Method
In a comprehensive software development environment, bottom-up testing is usually done first,
followed by top-down testing.
The process concludes with multiple tests of the complete application, preferably in scenarios
designed to mimic those it will encounter in customers' computers, systems, and networks.
rockinterview.in
Differences between Unit Testing and Integration Testing
The objective of Unit Testing is to test
each part of the program to make sure
that the individual parts are working
correctly.
Checks a single component of an
applications.
The scope of unit testing is narrow and
focuses on a small piece of code.
Unit testing only test the functionality of
individual units and may not catch
integration or system wide errors.
The objective of Integration Testing is
to combine modules in the
application and test if they work
together as a group.
The behavior of integration module is
considered in integration testing.
The scope of integration testing is
broad and puts the whole application
under test.
Integration Testing uncovers errors
that occur when integrating individual
modules into the overall system.
Unit Testing Integration Testing
rockinterview.in
Differences between Unit Testing and Integration Testing
It can be performed any time and
doesn’t have any dependencies.
Unit Tests shouldn’t have any
dependencies on outside systems.
It starts with module specification.
Pays attention to the behavior of single
modules.
Requires detailed visibility of the code.
It is usually carried out after Unit
Testing and before System Testing
Integration Tests depends on outside
systems like Database, Hardware,
etc.
It starts with interface specification.
Pays attention to integration among
modules.
Requires detailed visibility of the
integration structure.
Unit Testing Integration Testing
rockinterview.in
Differences between Unit Testing and Integration Testing
It is usually executed by developers.
It is easy to find errors.
It is not further sub divided into
different types.
Unit tests are easy to write and
execute.
It is a kind of white box testing.
It is usually executed by a testing
team.
It is relatively difficult to find errors.
It is further sub divided into top-down,
bottom-up integration testing and so
on
Integration tests require much more
effort to write and test effectively.
It comes under both black box and
white box testing.
Unit Testing Integration Testing
rockinterview.in
Conclusion
Testing is a way to ensure that the software developed delivers on the objectives in a
predictable manner.
Unit and Integration Testing are equally important to verify the working on individual
modules as well as the overall system. Therefore, Unit and Integration Testing should
be an integral part of the development process.
Unit Testing vs Integration Testing
Unit Testing vs Integration Testing

Unit Testing vs Integration Testing

  • 1.
    Unit Testing vs IntegrationTesting – What’s the difference
  • 2.
    rockinterview.in Confusion between UnitTesting and Integration Testing For someone looking to start a career in software testing, you might have came across terms such as Unit Testing and Integration Testing. You would have wondered what is the difference between the two. In Software Development Lifecycle, a software is developed by many developers who work on individual modules. These modules are then integrated into a full-fledged software. The testing specific to these modules and the integrated software is what is called Unit and Integration Testing respectively.
  • 3.
    rockinterview.in What is UnitTesting? At its core, unit testing is a type of test to check if an individual small piece of code is doing what it is supposed to do. A Unit Test is - Repeatable: You can rerun the same test as many times as you want. Consistent: Every time you run it, you get the same result. In Memory: It has no “hard” dependencies on anything not in memory (such as file system, databases, network) Fast: It should take less than half a second to run a unit test. Checking one single concern or “use case” in the system
  • 4.
    rockinterview.in What is IntegrationTesting? Integration testing is a type of testing to check if different pieces of the modules work together as a whole. An Integration Test might - Use system dependent values that change dynamically (such as DateTime.Now, or Environment.MachineName) Create objects of which it has little control (such as threads, random number generators) Reach out to external systems or local machine dependencies (from calling web services to using local configuration files) Test multiple things in the course of one test case (from database integrity to configurations, to protocols, to system logic; all in one go).
  • 5.
    rockinterview.in Two Methods forIntegration Testing Bottom-up integration testing typically begins with unit testing, followed by tests of progressively higher-level combinations of units called modules or builds. The top-down integration testing begins with the highest-level modules being tested first and progressively lower-level modules are tested afterwards. Bottom-up Method Top-down Method In a comprehensive software development environment, bottom-up testing is usually done first, followed by top-down testing. The process concludes with multiple tests of the complete application, preferably in scenarios designed to mimic those it will encounter in customers' computers, systems, and networks.
  • 6.
    rockinterview.in Differences between UnitTesting and Integration Testing The objective of Unit Testing is to test each part of the program to make sure that the individual parts are working correctly. Checks a single component of an applications. The scope of unit testing is narrow and focuses on a small piece of code. Unit testing only test the functionality of individual units and may not catch integration or system wide errors. The objective of Integration Testing is to combine modules in the application and test if they work together as a group. The behavior of integration module is considered in integration testing. The scope of integration testing is broad and puts the whole application under test. Integration Testing uncovers errors that occur when integrating individual modules into the overall system. Unit Testing Integration Testing
  • 7.
    rockinterview.in Differences between UnitTesting and Integration Testing It can be performed any time and doesn’t have any dependencies. Unit Tests shouldn’t have any dependencies on outside systems. It starts with module specification. Pays attention to the behavior of single modules. Requires detailed visibility of the code. It is usually carried out after Unit Testing and before System Testing Integration Tests depends on outside systems like Database, Hardware, etc. It starts with interface specification. Pays attention to integration among modules. Requires detailed visibility of the integration structure. Unit Testing Integration Testing
  • 8.
    rockinterview.in Differences between UnitTesting and Integration Testing It is usually executed by developers. It is easy to find errors. It is not further sub divided into different types. Unit tests are easy to write and execute. It is a kind of white box testing. It is usually executed by a testing team. It is relatively difficult to find errors. It is further sub divided into top-down, bottom-up integration testing and so on Integration tests require much more effort to write and test effectively. It comes under both black box and white box testing. Unit Testing Integration Testing
  • 9.
    rockinterview.in Conclusion Testing is away to ensure that the software developed delivers on the objectives in a predictable manner. Unit and Integration Testing are equally important to verify the working on individual modules as well as the overall system. Therefore, Unit and Integration Testing should be an integral part of the development process.