Unit 4 SE Updated
Unit 4 SE Updated
Testing
What is Testing?
• “Testing is the process of executing a program with the intent of finding errors.”
• Testing a program consists of providing the program with a set of test inputs (or test cases) and
observing if the program behaves as expected.
• If the program fails to behave as expected, then the conditions under which failure occurs are
noted for later debugging and correction.
• Some commonly used terms associated with testing are:
i. Failure: This is a manifestation of an error (or defect or bug). But, the mere presence of an
error may not necessarily lead to a failure.
ii. Test case: This is the triplet [I,S,O], where I is the data input to the system, S is the state of the
system at which the data is input, and O is the expected output of the system.
iii. Test suite: This is the set of all test cases with which a given software product is to be tested.
Software Testing
• Software testing can be divided into two steps:
1. Verification: it refers to the set of tasks that ensure that software
correctly implements a specific function.
2. Validation: it refers to a different set of tasks that ensure that the
software that has been built is traceable to customer requirements.
Verification: “Are we building the product right?”
Validation: “Are we building the right product?”
Static VS Dynamic Testing
white-box black-box
methods methods
Methods
Strategies
Black-box Testing
• Black-box technique is one of the major techniques in dynamic testing
for designing effective test cases.
• This technique considers only the functional requirements of the
software or module. In other words, the structure or logic of the
software is not considered. Therefore, this is also known as functional
testing.
• The software system is considered as a black box, taking no notice of its
internal structure, so it is also called as black-box testing technique.
Input test data is given to the system, which is a black box to the tester,
and results are checked against expected outputs after executing the
software, as shown in Fig. 4.1.
Black-box testing attempts to find errors in the following categories: 1
1.To test the modules independently .
2.To test the functional validity of the software so that incorrect or missing
functions can be recognized.
3 .To look for interface errors
4.To test the system behavior and check its performance .
5. To test the maximum load or stress on the system .
6.To test the software such that the user/customer accepts the system within
defined acceptable limits
1.BOUNDARY VALUE ANALYSIS (BVA)
• It has been observed that test cases designed with boundary input values have a
high chance to find errors. It means that most of the failures crop up due to
boundary values.
• BVA is considered a technique that uncovers the bugs at the boundary of input
values. Here, boundary means the maximum or minimum value taken by the
input domain. For example, if A is an integer between 10 and 255, then boundary
checking can be on 10(9,10,11) and on 255(256,255,254). Similarly, B is another
integer variable between 10 and 100, then boundary checking can be on
10(9,10,11) and 100(99,100,101), as shown in Fig. 4.2
BVA offers several methods to design test cases as discussed in the following sections:
1. BOUNDARY VALUE CHECKING (BVC)
2. ROBUSTNESS TESTING METHOD.
3. WORST-CASE TESTING METHOD
1.1 BOUNDARY VALUE CHECKING (BVC)
• In this method, the test cases are designed by holding one variable at its extreme
value and other variables at their nominal values in the input domain.
• The variable at its extreme value can be selected at:
(a) Minimum value (Min)
(b) Value just above the minimum value (Min+ )
(c) Maximum value (Max)
(d) Value just below the maximum value (Max−)
Also known as closed box/data driven testing. Also knwon as clear box/structural testing.
End users, testers and developers. Normally done by testers and developers.
THis can only be done by trial and error method. Data domains and internal boundaries can be
better tested.
Test process in software development
V-model:
acceptance
requirements test
system
specification test
detailed integration
design test
implementation unit
code test
Unit Testing
• Involves testing a single isolated module
• Note that unit testing allows us to isolate the errors to a single module
• we know that if we find an error during unit testing it is in the module
we are testing
• Modules in a program are not isolated, they interact with each other.
Possible interactions:
• calling procedures in other modules
• receiving procedure calls from other modules
• sharing variables
• For unit testing we need to isolate the module we want to test, we do this
using two things
• drivers and stubs
Stubs and Drivers :
• The Stubs and Drivers are considered as elements which are equivalent to to-do
modules that could be replaced if modules are in their developing stage, missing
or not developed yet, so that necessity of such modules could be met. Drivers
and stubs simulate features and functionalities, and have ability to serve features
that a module can provide. This reduces useless delay in testing and makes the
testing process faster.
• Stubs are mainly used in Top-Down integration testing while the Drivers are
used in Bottom-up integration testing, thus increasing the efficiency of testing
process.
• 1.Stubs :
Stubs are developed by software developers to use them in place of modules, if
the respective modules aren’t developed, missing in developing stage, or are
unavailable currently while Top-down testing of modules. A Stub simulates
module which has all the capabilities of the unavailable module. Stubs are used
when the lower-level modules are needed but are unavailable currently.
• Drivers :
Drivers serve the same purpose as stubs, but drivers are used in Bottom-up integration testing and are
also more complex than stubs. Drivers are also used when some modules are missing and unavailable at
time of testing of a specific module because of some unavoidable reasons, to act in absence of required
module. Drivers are used when high-level modules are missing and can also be used when lower-level
modules are missing.
• Ex : Suppose, you are told to test a website whose corresponding primary modules are, where each of
them is interdependent on each other, as follows:
• Module-A : Login page website,
• Module-B : Home page of the website
• Module-C : Profile setting
• Module-D : Sign-out page
• It’s always considered good practice to begin development of all modules parallelly because as soon as
each gets developed they can be integrated and could be tested further as per their corresponding
interdependencies order with a module. But in some cases, if any one of them is in developing stage or
not available in the testing process of a specific module, stubs or drivers could be used instead.
• Assume Module-A is developed. As soon as it’s developed, it undergoes testing, but it requires Module-
B, which isn’t developed yet. So in this case, we can use the Stubs or Drivers that simulate all features
and functionality that might be shown by actual Module-B. So, we can conclude that Stubs and drivers
are used to fulfill the necessity of unavailable modules. Similarly, we may also use Stubs or Drivers in
place of Module-C and Module-D if they are too not available.
Integration Testing
• The modules that may work properly and independently may not
work when they are integrated.
• Integration Testing will test whether the modules work well
together.
• This will check whether the design is correct.
• Integration testing: Integrated collection of modules tested as a
group or partial system
• Integration plan specifies the order in which to combine modules
into partial systems
• Different approaches to integration testing
• Bottom-up
• Top-down
• Big-bang
• Sandwich
Module Structure
A B
• We assume that
the uses hierarchy is
a directed acyclic graph.
• If there are cycles merge
D them to a single module
level 1 C H
level 0 E F G I
• Requires a module driver for each module to feed the test case input to the interface
of the module being tested
• However, stubs are not needed since we are starting with the terminal modules
and use already tested modules when testing modules in the lower levels
Bottom-up Integration
A B
C H
E F G I
Top-down Integration
• Only modules tested in isolation are the modules which are at
the highest level
A B
C
H
E F G I
Other Approaches to Integration
• Sandwich Integration
• Compromise between bottom-up and top-down testing
• Simultaneously begin bottom-up and top-down testing and meet at a
predetermined point in the middle
• Instead of completely going for top down or bottom up, a layer is
identified in between.
• Above this layer we go for top down and below this layer bottom up.
• Do not use a coding style that is too clever or too difficult to understand
• Do not use an identifier for multiple purposes
• The code should be well-documented
• The length of any function should not exceed 10 source lines
• Do not use goto statements
• Do not do hard coding