Unit Validation Testing
Unit Validation Testing
. Mohapatra
Prof. Durga Prasad
Professor
Dept.of CSE, NIT Rourkela
Testing Levels
4 Testing Levels
Software tested at 4 levels:
◦ Unit testing
◦ Integration testing
◦ System testing
◦ Regression testing
Test Levels
Unit testing
◦ Test each module (unit, or component) independently
Acceptance testing
◦ Validation of system functions by the customer
Levels of Testing
What users Acceptance
really need testing
Simulation
Unit testing
Integration testing
12
•Software validation is achieved by a series of black-
box tests that demonstrate conformity with
requirements.
•Both test plan and test procedure are designed to
ensure that
•Functional requirements are satisfied
•Behavioral characteristics achieved
•Performance requirements attained
13
V&V activities
14
Unit Validation Testing
•Since unit is the smallest building block of the software
system, it is the first piece of system to be validated.
Before we validate the entire software, units or
modules must be validated.
•Unit testing is normally considered an adjunct to the
coding step.
•Units must also be validated to ensure that every unit
of software has been built in the right manner in
conformance with user requirements.
Unit Validation Testing Cont…
•Unit tests ensure that the software meets at least a
baseline level of functionality prior to integration and
system testing.
•While developing the software, if the developer
detects and removes the bug, it offers significant
savings of time and costs.
•This type of testing is largely based on black-box
techniques.
Module
•Software is divided into modules but a module is not
an isolated entity.
•The module under consideration might be getting
some inputs from another module or the module is
calling some other module.
•It means that a module is not independent and cannot
be tested in isolation.
•While testing the module, all its interfaces must be
simulated if the interfaced modules are not ready at the
time of testing the module under consideration.
Drivers
•Software test drivers are programs which simulate the
behaviors of software components (or modules) that are the
control modules of a under test module.
• Control the test cases.
•A driver module should contain the non-local data
structures accessed by the module under test.
•Additionally, it should also have the code to call the different
functions of the unit under test with appropriate parameter
values for testing.
• The driver module may print or interpret the results
produced by the module under testing.
Example
•For example, see the design hierarchy of the modules
in Figure 1.
•Suppose module B is under test. In the hierarchy,
module A is a superordinate of module B.
•Suppose module A is not ready and B has to be unit
tested.
Design Hierarchy of an example system
Example
•But they can also be used by any other person who is validating
the unit.
Example
Consider the following program:
main()
{
Int a, b, c, sum, diff, mul;
scanf(“%d %d %d”, &a, &b, &c);
sum = calsum(a,b,c);
diff = caldiff(a,b,c);
mul = calmul(a,b,c);
printf(“%d %d %d”, sum, diff, mul);
}
calsum(int x, int y, int z)
{
int d;
d = x + y + z;
return(d);
}
Example
(a) Suppose main() module is not ready for the testing of
calsum() module. Design a driver module for main().
(b) Modules caldiff() and calmul() are not ready when called in
main(). Design stubs for these two modules.
Solution
Solution
Summary
Discussed different levels of testing.
Explained Verification vs.Validation.
Presented V & V activities.
Discussed unit validation testing.
Explained the concept of Drivers and Stubs with an
example.
41
References
1. Rajib Mall, Fundamentals of Software Engineering,
(Chapter – 10), Fifth Edition, PHI Learning Pvt.
Ltd., 2018.
2. Naresh Chauhan, Software Testing: Principles and
Practices, (Chapter – 7), Second Edition, Oxford
University Press, 2016.
Thank You