SE,Unit-4, Software Testing
SE,Unit-4, Software Testing
User
Unit Testing
Testing
Module
Testing
Sub-system
Testing
System
L Testing
Acceptance
Testing
Component Integration
Testing Testing
- - - - - - -
Fig.8.3.
1. Unit Testing
A. Interface
I s number
of input parameter equal to number of arguments?
I s parameter and argument attributes match ?
Are parameters passed in correct order ?
Are Global variable definitions consistent across modules?
If module does I/O
() File attributes correct?
i) Open/close statements correct ?
(iii) Buffer size match record size ?
(iv) File opened before use?
() End of file condition handled?
(vi) I/O errors handled ?
B. Local data structures
(common source of errors)
Test cases in unit testing should uncover errors, such as
Comparison of different data types
Incorrect logical operators or precedence
.Expectation of equality when precision error makes equality
Incorrect comparison of variables unlikely
Improper loop termination
Failure to exit when divergent iteration is
encountered
Improperly modified loop variables
. Overflow, underflow, address exceptions.
C.Error handling
D
Test Sequence 1 Test Sequence 2 Test Sequence 3
Fig. 8.7.
According to Fig. 8.7, in test sequence 1 tests T,, T, and
of module A and module B. If these are T2 are first run ona system composed
corrected or error free then module C is
test sequence 2 and then tests
T, T2 and integrated, 1.e,
T, are repeated, problem arises in these tests,
if a
they interact with the new module. The source of the problem is localized, thus it then
defect location and repair. Finally, module D is integrated, i.e., test simplifies
sequence 3 is then tested
using existing (T, toT) and new tests (T).
(c) Top-Down Integration Testing
Top-down integration testing is an incremental approach to construction of program
eos. Modules are integrated by moving downward
through he control hierarchy beginning with the main control
s t r u e
M,
module.
InTop-down method, top elements of systemareintegrated
tested in beginning while units and basic level components M4
and e
are eval luated at the end of testing phas. This approach of
oration
egration testing is beneficial, since it identifieS
implementation of functionalrequirements, high-level M]M][M
romponentsand iOgic ot componentsearly on intesting.
Additionally it allows tester to evaluate each branch of the
System under development..
(i) Depth-first integratjon: This would integrate all Fig. 8.8.
omponents on a major control path of the structure. For
example, M, M, and M, would be integrated first. Next, M, or M, would be integrated. Then,
the central and right-hand control paths are built.
(ii) Breadth-firstintegration: This incorporates all components directly subordinate at
ach level,moving across the structure horizontally. From above figure 8.8, components M, Mg
and M, would be integrated first. The next control level Mg, M, and so on follows.
The integration process is performed in a series offive steps:
1. The main-control module is used as a test driver and stubs are substituted for
all
components directly subordinate to the main control module.
subordinate
2. Depending on the integration approach selected (i.e., depth or breadth first),
stubs are replaced one at a time with actual components.
3. Tests are conducted as each component is integrated.
4. On completion of each set of tests, another stub is replaced with the real component.
introduced.
5.Regression testing may be conducted to ensure that new errors have not been
released or shown then most of
The advantage to this way of testing is that if a prototype is
to maintain the code and there
the main functionality will already be working. It is also easy
will be better control in terms of errors so most of the errors
would be taken out before going to
the next stage of testing.
test data. The
is that it is hard to test the lower level components using
The disadvantage modules.
is that lower level modules may not be tested as much as the upper level
other thing
(d) Bottom-up Integration Testing
where you test the lower level components and start
This is the opposite to top-down level components. The components will be separated
ng your way upwards to the higher then
important modules will be worked on first,
n e level of importanee and the least integrating components at
each level before moving
Wy you would work your way up by
upwards.
construction and testingwith
its n a m e implies, begins
Dottom-up integration testing, as
A bottom-upintegration strategy
the the program structur.
mponents at the lowest level in
4y be implemented with the following steps
called builds) that perform
Low-level components are combined intoclusters (sometimes
specific software sub-functions. input anc
is written to coordinate test case
A driver (a control program for testing)
output.
8.22. SYSTEM TESTING
Subsystems re integrated to make up the entire
system. The
finding errors that result from unanticipated interactions testing process is concerned with
between subsystems and system
components. It is also concerned with validating that the meets its functional and non-
functional requirements. There are essentially three mainsystem
kinds of system testing:
Alpha testing
Beta testing
Acceptance testing
Alpha Testing
The customer under the project team's guidance conducts the
alpha test at the developer's
site. In this test, users test the software on the development platform
and point out errors for
correction. However, the alpha test, because a few users on the dewelopment platform conduct
it, has limited ability toexpose errors and correct them. Alpha tests are conducted in a controlled
environment. Itis a simulation of rea-life usage. Once the alpha test is complete,thesoftware
product 1s ready for transition to thecustomersite for implementationand development.
Beta Testing
Beta testing is the system testing performed by a selected group of friendly customers? If
the system is complex, the software is not taken for implementation directly. It is installed and
all users are asked touse the software in testing mode; this is not live usage. This is called the
beta test. Beta tests are conducted at the customersitein an environment where the software
1sexposed to a number of users. The developer may or may not be present while the software is
in use. So, betatesting is a real-life software experience without actualimplementation. In th+s
test, end users record their observations,mistakes errors and so on and reportthem periodically
In a beta test, the user may modification, a major change, or a deviation
suggest a
Lon. The
development has to
examine the proposed change and put it into the change managem:
system for smooth change from just developedsoftware to a revised, better
standard practice to put all such changes in subsequent version releases.
softwarare. eIt is
Acceptance Testing
Acceptance testing (also known as acceptance testing) is a type of testing carried o e
user
order to verify if the produet is developed as per the standards and specified criteria andmat in
all the requirements specified by customer. Thus, acceptance testing is the nd meets
system testi
performed by the customer to determine whether to ting
accept or reject the delivery of the svsto
conductedem
When customer software is built for one customer, a series of acceptance tests are
enable the customer to validate all requirements. to
Acceptance testing falls under black box testing methodology where the user is not
Ver
much interested in internal working/coding of the system, but evaluates the ery
overall functionin
of the system and compares it with the
is considered to be one of the most
requirements specified by them. User acceptance testing
important testing by user before the system is finally delivere
or handed over to the end user.
Fig. 8.16.
5.Optimizations.
Why we do White-Box Testing
Toensure:
module have been exercised at least
once.
That all independent paths within a
their true and false values.
All logical decisions verified on internal
their boundaries and within their operational bounds
All loops executed at
data structures validity.
Need of White-Box Testing
To discover the following types of bugs:
into our work when we design and implement functions,
Logical error tend to creep
controls that are out of the program.
conditions
of the program and the actual
or
errors due to
difference between logical flow
The design
implementation.
Typographical errors and syntax
checking.
2,$tructural Testing
is present in the code. structural
/ Structural testing examines source code and analvses what
analysis. This implies
often dynamic, meaning that code is executed during
testing techniques are
fille management and execution
a high-test cost due to compilation or interpretation, leakage,
time. Test cases are derived from analysis of the program control flow.
between program regions
A Control Flow Graph is a representation of the flow of control
such as a group of statements bounded by a single entry and exit point.
Structural testing cannot expose errors of code omission but can
estimate the test suite
adequacy in terms of code that is, execution of components by the test suite or its
coverage,
fault-finding ability.
The following are some important types ofstructural testing:
Statement Coverage Testing
Branch Coverage Testing
Condition Coverage Testing
Loop Coverage Testing
Path Coverage Testing
Domain and Boundary Testing
Data-flow Testing
Statement coverage: Statement coverage is a measure of the percentage of statements
that have been executed by test cases. Our objective should be to achieve 100% statement
coverage through testing.
Branch/ decision coverage: Test coverage criteria requires enough test cases such
that each condition in a decisions takes on all possible outcomes at least once, and each
point of entry to a program or subroutine is invoked at least once. That is, every branch
(decision) taken each way, true and false. It helps in validating all the branches in the code
making sure that no branch leads to abnormal behaviour of the application.
Condition coverage: (or predicate covered) Has each boolean sub-expression evaluated
both to true and false ? This does not necessarily imply decision coverage.
Condition/decision coverage: Both decision and condition coverage should be satisfied.
Loop coverage: This criteria requires sufficient test cases for all program loops to be
acuted for zero, one, two and many iterations covering initialization, typical running and
e x e c u
termination conditions.
Path coverage: In path coverage we write test cases to ensure that each and every
nath has been traversed at least once. One way to better understand path coverage
p
Draw a flow graph to indicate corresponding logic in the program.
Calculate individual paths in the flow graph.
Run the program in all possible ways to cover every statement.
Understanding path coverage is a good way to better understand code coverage.
Domain and Boundary testing: Domain testing is a form of path coverage. Path domains
are a subset of the program input that causes execution of unique paths. The input data can
be derived from the program control flow graph. Test inputs are chosen to exercise each
path and also the boundaries of each domain.
The drawback of domain and boundary analysis is that it is only suitable for programs with
a small number of input variables and with simple linear predicates.
Data flow testing: Data flow testing focus on the points at which variables receive
values, and the points at which the values are used. This kind of testing serves as a reality
check on path testing and that's why many authors view it as a path testing technique.
This technique requires sufficient test cases for each feasible data flow to be executed at
least once. Data flow analysis studies the sequences of actions and variables along program
paths. It can be considered and applied a s both static and as a dynamic technique.
Data-flow testing uses the flow graph to explore unreasonable things thatcan
happen to
data. Enough paths must be selected to ensure that each and every variable has been initialized
prior to its use or that all defined variables have been used or referenced for something.
Data flow testing is considered viable for incorrect uses of variables and constants as well
as misspelled identifiers. As with code coverage strategies, data flow testing cannot deteet missing
statements.
8.28.3. Disadvantages of White-Box Testing
Despite benefits, white-box testing has its drawbacks. Some of the most commonly citaa
1ssues are ted
Complexity. Being able to see every constituent part of an application meansthat.
at a
tester must have detailed programmatic knowledge of the application in order to wor
withit properly. This high-degree of complexity requires a much more highly skille
Nork
led
individual to develop test case.
Fragility. While introspection is supposed to overcome the issue of application change
nges
breaking test scrips the reality is that often the names of objects change during produet
development or new paths through the application are added. The fact that white-be
testing requirestest scripts to betightly tied to the underlying code of an application
means that changes to the code will often cause white-box test scripts to break.Thio
then, introduces a high degree of script maintenance into the testing process.
Integration. For white-box testing to achieve the degree of introspection required it
the
must be
tightly integrated with application being tested. This
creates a few problema
To betightlyintegrated with thecode youmustinstallthe white-boxtoolonthesystem
on which the application is running. This is okay, but where one wishes to eliminate
the possibility that the testing tool is what is causing either a performance or operational
problem, this becomes impossible to resolve. Another issue that arises is that of platform
support. Due to the highly integrated nature of white-box testing tools many do not
provide support for more than one platform, usually Windows. Where companies have
applications that run on other platforms, they either need to use a different tool or
resort to manual testing.
.It is
nearly impossible to look every bit of code to find out hidden which may
errors,
create problems resulting in failure of the application.
8,29. BLACK-BOX TESTING (FUNCTIONAL TESTING)
Black-box testing involves looking at the specifications and does not require examiningthe
code of a program. Black-box testing is done from the customer's viewpoint. The test engineer
engaged in black-box testing only knows the setof inputs and expected outputs and is unaware
of how those inputs are transformed into outputs by the software. Black-box tests are convenient
to administer because they use the complete finished product and do not
of its construction require any knowledge
Generally, black-box testing attempts to uncover the following:
1. Incorrect functions.
2. Data structure errors.
3. Missing functions.
4. Performance errors.
5. External database access errors.
6. Initializing and termination
errors
Black-box testing is also called functional testing because the tester is
the functionality and not the implementation of the software. only concerned w
Black-box or functional testing are designed to answer the
(i) How is functional validity tested?
following questions:
(i) How is system behaviour and performance tested?
What class of input will make good test cases?
(iv) Is tthe system rticularly sensitive to certain input values?
o) How are the boundaries of data class isolated?
u)What data rates and data volume can a system tolerate?
What effect will specific combination of data have on system operation?
(
why
Black-box Testing ?
Black-box testing helps in the overall functionality verification of the system under test.
1. It helps in /dentifyingany incomplete, inconsistentrequirement as well as any issues
involvedwhen thesystem is tested as a complete entity.
2. Black box testing handles valid and invalid inputs.
3. Black box testing addresses the stated requirements as well asimplied requirements.
4. Black box testing encompasses the end user perspectives.
8.4. DEBUGGING
Debuggingoceurs as a consequence ofsuccessfultesting.The goal oftestingis toidentify errors
(bugs in the program. Atter 1dentilication of place, we examine that portion to identify the
cause oftheproblem. This process iscalled debugging.Hencedebuggingistheactivity oflocating
and correcting errors.
The debugging process is illustrated in the figure
Execution
Test casess Result
of cases
Additional
Test - Suspected
causes
Debugging
Regression Corrections
ldentified
causes
tests
Fig. 8.20. Debugging process
282 OSoftware Engineering
is
Thus the outcomes of the debugging process
The cause will be found, corrected and removed.
v2. The cause will not be found.
cannot
Locate
pertinent data
Organize Study the Devise a
the data relationship hypothesis
can
Prove the
hypothesis cannot
can
Fix the
error
validation.
one single remains for
Collect
more data
() Debugging by Testing
This type of debugging involves test cases. These are two types of test
cases
The design is analyzed (abstracted) to produce the original reguirements specification. The
change requests are then applied to this requirements specifications to arrive at the new
requirements specitications. At the design, module specitications and coding a substantial
reuse is made from the reverse engineered products. An important advantage of this approach
is that it produces a more structured designed compared to what the original product
hai
produces good documentatioin, and very often results in increased efficiency. The efficiency
improvements are brought about by a more efficient design. However, this approach is more
costly than the first approach. An empirical study indicates that process 1 is preferable
when the amount of rework is no more than 15%. Besides the amount of rework, several
other factors might affect the decision regarding using process model 1 over process model2
Reengineering might be preferable for products, which exhibit a high failure rate
Reengineering might also be preferable for legacy products having poor design and
code structure.
Change Requirements
Requirements Requirements
Reverse
Specification Specification
Engineering Forward
Engineering!
Design
Design
Module
Specification Module
Specification
Code
Code
---