Lecture 3.3.5 Test Strategies
Lecture 3.3.5 Test Strategies
UNIT-3
Bachelor of Computer Applications
Software Engineering
(21CAT-312/21SCT-312/22CAT-213/22SCT-213)
• The purpose of unit testing is to test the correctness of isolated code. A unit
component is an individual function or code of the application. White box testing
approach used for unit testing and usually done by the developers.
• Whenever the application is ready and given to the Test engineer, he/she will start
checking every component of the module or module of the application
independently or one by one, and this process is known as Unit
testing or components testing.
Why Unit Testing?
• In a testing level hierarchy, unit testing is the first level of testing done before
integration and other remaining levels of the testing. It uses modules for the
testing process which reduces the dependency of waiting for Unit testing
frameworks, stubs, drivers and mock objects are used for assistance in unit testing.
Objective of Unit Testing
• The objective of Unit Testing is:
• To isolate a section of code.
• To verify the correctness of the code.
• To test every function and procedure.
• To fix bugs early in the development cycle and to save costs.
• To help the developers to understand the code base and enable them to make
changes quickly.
• To help with code reuse.
Unit Testing Techniques
• There are 3 types of Unit Testing Techniques. They are
• Black Box Testing: This testing technique is used in covering the unit tests for
input, user interface, and output parts.
• White Box Testing: This technique is used in testing the functional behavior of
the system by giving the input and checking the functionality output including the
internal design structure and code of the modules.
• Gray Box Testing: This technique is used in executing the relevant test cases, test
methods, test functions, and analyzing the code performance for the modules.
Unit Testing Tools
• Here are some commonly used Unit Testing tools:
• Jtest
• Junit
• NUnit
• EMMA
• PHPUnit
Advantages of Unit Testing
• Unit Testing allows developers to learn what functionality is provided by a unit
and how to use it to gain a basic understanding of the unit API.
• Unit testing allows the programmer to refine code and make sure the module
works properly.
• Unit testing enables testing parts of the project without waiting for others to be
completed.
• Early Detection of Issues: Unit testing allows developers to detect and fix issues
early in the development process, before they become larger and more difficult to
fix.
• Improved Code Quality: Unit testing helps to ensure that each unit of code works
as intended and meets the requirements, improving the overall quality of the
software.
Disadvantages of Unit Testing
• The process is time-consuming for writing the unit test cases.
• Unit Testing will not cover all the errors in the module because there is a chance
of having errors in the modules while doing integration testing.
• Unit Testing is not efficient for checking the errors in the UI(User Interface) part
of the module.
• It requires moe time for maintenance when the source code is changed frequently.
• It cannot cover the non-functional testing parameters such as scalability, the
performance of the system, etc.
Introduction of Integration Testing
• Integration testing is the second level of the software testing process comes after
unit testing. Integration testing is the process of testing the interface between two
software units or modules. It focuses on determining the correctness of the
interface. The purpose of integration testing is to expose faults in the interaction
between integrated units. Once all the modules have been unit tested, integration
testing is performed.
• Unit testing uses modules for testing purpose, and these modules are combined
and tested in integration testing. The Software is developed with a number of
software modules that are coded by different coders or programmers. The goal of
integration testing is to check the correctness of communication among all the
modules.
Introduction of Integration Testing
Integration test approaches
• 1. Big-Bang Integration Testing – It is the simplest integration testing approach,
where all the modules are combined and the functionality is verified after the
completion of individual module testing. In simple words, all the modules of the
system are simply put together and tested.
• This approach is practicable only for very small systems. If an error is found
during the integration testing, it is very difficult to localize the error as the error
may potentially belong to any of the modules being integrated. So, debugging
errors reported during big bang integration testing is very expensive to fix.
Integration test approaches
• Bottom-Up Integration Testing – In bottom-up testing, each module at lower
levels are tested with higher modules until all modules are tested.
• The primary purpose of this integration testing is that each subsystem tests the
interfaces among various modules making up the subsystem. This integration
testing uses test drivers to drive and pass appropriate data to the lower-level
modules.
Integration test approaches
• Top-Down Integration Testing – Top-down integration testing technique is used
in order to simulate the behaviour of the lower-level modules that are not yet
integrated.
• In this integration testing, testing takes place from top to bottom. First, high-level
modules are tested and then low-level modules and finally integrating the low-
level modules to a high level to ensure the system is working as intended.
Integration test approaches
• Mixed Integration Testing – A mixed integration testing is also called
sandwiched integration testing. A mixed integration testing follows a combination
of top down and bottom-up testing approaches. In top-down approach, testing can
start only after the top-level module have been coded and unit tested.
• In bottom-up approach, testing can start only after the bottom level modules are
ready. This sandwich or mixed approach overcomes this shortcoming of the top-
down and bottom-up approaches. It is also called the hybrid integration testing.
also, stubs and drivers are used in mixed integration testing.
Applications of Integration Testing
• Identify the components: Identify the individual components of your application
that need to be integrated. This could include the frontend, backend, database, and
any third-party services.
• Create a test plan: Develop a test plan that outlines the scenarios and test cases
that need to be executed to validate the integration points between the different
components. This could include testing data flow, communication protocols, and
error handling.
• Set up test environment: Set up a test environment that mirrors the production
environment as closely as possible. This will help ensure that the results of your
integration tests are accurate and reliable.
• Execute the tests: Execute the tests outlined in your test plan, starting with the
most critical and complex scenarios. Be sure to log any defects or issues that you
encounter during testing.