Unit I Foundations of Software Testing
Unit I Foundations of Software Testing
Unit I Foundations of Software Testing
Why do we test Software?, Black-Box Testing and White-Box Testing, Software Testing
Life Cycle, V-model of Software Testing, Program Correctness and Verification,
Reliability versus Safety, Failures, Errors and Faults (Defects), Software Testing
Principles, Program Inspections, Stages of Testing: Unit Testing, Integration Testing,
System Testing
1. Introduction:
1
Testing is generally described as a group of procedures carried out to evaluate some
aspect of a piece of software.
Testing can be described as a process used for revealing defects in software, and for
establishing that the software has attained a specified degree of quality with respect to
selected attributes.
Testing is defined as a set of activities which are well planned in advance and also
conducted systematically. It is a process of checking the software product in a
predefined way to know if the behavior is same as the expected one.
Note that testing and debugging, or fault localization, are two very different activities.
The debugging process begins after testing has been carried out and the tester has
noted that the software is not behaving as specified.
Debugging, or fault localization is the process of (1) locating the fault or defect, (2)
repairing the code, and (3) retesting the code.
Testing must be planned, testers should be trained, the process should have
associated quantifiable goals that can be measured and monitored. Testing as a
process should be able to evolve to a level where there are mechanisms in place for
making continuous improvements.
2
1.2 Black-Box Testing
Black-box testing (also known as datadriven or input/output-driven testing). Your
goal is to be completely unconcerned about the internal behavior and structure of the
program. Instead, concentrate on finding circumstances in which the program does not
behave according to its specifications.
A good test case as one that has a reasonable probability of finding an error; it also
stated that an exhaustive input test of a program is impossible . When testing a
program, you are limited to a small subset of all possible inputs. Of course, then, you
want to select the ‘‘right’’ subset, that is, the subset with the highest probability of
finding the most errors.
One way of locating this subset is to realize that a well-selected test case also
should have two other properties:
1. It reduces, by more than a count of one, the number of other test cases that
must be developed to achieve some predefined goal of ‘‘reasonable’’ testing.
2. It covers a large set of other possible test cases. That is, it tells us something
about the presence or absence of errors over and above this specific set of input
values.
3
Test-case design by equivalence partitioning proceeds in two steps:
1. If an input condition specifies a range of values (e.g., ‘‘the item count can be
from 1 to 999’’), identify one valid equivalence class (1999).
2. If an input condition specifies the number of values (e.g., ‘‘one through six
owners can be listed for the automobile’’), identify one valid equivalence class
and two invalid equivalence classes (no owners and more than six owners).
If there is any reason to believe that the program does not handle elements in an
equivalence class identically, split the equivalence class into smaller equivalence
classes.
4
2. Until all valid equivalence classes have been covered by (incorporated into)
test cases, write a new test case covering as many of the uncovered valid
equivalence classes as possible.
3. Until your test cases have covered all invalid equivalence classes, write a
test case that covers one, and only one, of the uncovered invalid equivalence
classes.
5
record is a title used as a title on each output report. The next set of records
describes the correct answers on the exam. These records contain a ‘‘2’’ as the
last character in column 80. In the first record of this set, the number of
questions is listed in columns 1–3 (a value of 1–999). Columns 10–59 contain
the correct answers for questions 1–50 (any character is valid as an answer).
Subsequent records contain, in columns 10–59, the correct answers for
questions 51–100, 101–150, and so on. The third set of records describes the
answers of each student; each of these records contains a ‘‘3’’ in column 80.
For each student, the first record contains the student’s name or number in
columns 1– 9 (any characters); columns 10–59 contain the student’s answers
for questions 1–50. If the test has more than 50 questions, subsequent records
for the student contain answers 51–100, 101–150, and so on, in columns 10–59.
The maximum number of students is 200. The input data are illustrated in
Figure 4.4.
7
The basic notation for the graph is shown in Figure 4.5 Think of each node as having
the value 0 or 1; 0 represents the ‘‘absent’’ state and 1 represents the ‘‘present’’ state..
Consider the MTEST program in the section on boundary value analysis. The
following additional tests come to mind when using the error-guessing technique
8
Does the program accept ‘‘blank’’ as an answer?
A type-2 (answer) record appears in the set of type-3 (student) records. A
record without a 2 or 3 in the last column appears as other than the initial (title)
record.
Two students have the same name or number. The number-of-questions field
has a negative value.
9
A stronger logic coverage criterion is known as decision coverage or branch
coverage. This criterion states that you must write enough test cases that each
decision has a true and a false outcome at least once. In other words, each branch
direction must be traversed at least once. Examples of branch or decision statements
are switch-case, do-while, and if-else statements. Multipath GOTO statements qualify
in some programming languages such as Fortran.
Decision coverage usually can satisfy statement coverage. Since every statement
is on some sub path emanating either from a branch statement or from the entry point
of the program, every statement must be executed if every branch direction is
executed. There are, however, at least three exceptions:
Programs with no decisions.
Programs or subroutines/methods with multiple entry points. A given statement
might be executed only if the program is entered at a particular entry point.
Statements within ON-units. Traversing every branch direction will not
necessarily cause all ON-units to be executed.
10
It should be easy to see that a set of test cases satisfying the multiple condition
criterion also satisfies the decision coverage, condition coverage, and
decision/condition coverage criteria.
11
to improve the quality of the product. Let’s quickly see what all stages are involved in
typical Software Testing Life Cycle
Following steps are involved in Software Testing Life Cycle (STLC). Each step is
have its own Entry Criteria and deliverable.
Requirement Analysis
Test Planning
Test Case Development
Environment Setup
Test Execution
Test Cycle Closure
Requirement Analysis is the very first step in Software Testing Life Cycle (STLC).
In this step Quality Assurance (QA) team understands the requirement in terms
of what we will testing & figure out the testable requirements. If any conflict, missing
or not understood any requirement, then QA team follow up with the various
stakeholders like Business Analyst, System Architecture, Client, Technical
Manager/Lead etc to better understand the detail knowledge of requirement.
12
At the end of this stage, the testing team should have a clear understanding
of the software requirements and should have identified any potential issues
that may impact the testing process.
Test Planning
Test Planning is most important phase of Software testing life cycle where all
testing strategy is defined. This phase also called as Test Strategy phase. In this
phase typically Test Manager (or Test Lead based on company to company) involved
to determine the effort and cost estimates for entire project. This phase will be kicked
off once the requirement gathering phase is completed & based on the requirement
analysis, start preparing the Test Plan. The Result of Test Planning phase will be Test
Plan or Test strategy & Testing Effort estimation documents. Once test planning
phase is completed the QA team can start with test cases development activity.
13
Test Case Development
The test case development activity is started once the test planning activity is
finished. This is the phase of STLC where testing team write down the detailed test
cases. Along with test cases testing team also prepare the test data if any required for
testing. Once the test cases are ready then these test cases are reviewed by peer
members or QA lead.
14
Test Execution
Once the preparation of Test Case Development and Test Environment setup is
completed then test execution phase can be kicked off. In this phase testing team start
executing test cases based on prepared test planning & prepared test cases in the prior
step.
Test Closure:
Call out the testing team member meeting & evaluate cycle completion
criteria based on Test coverage, Quality, Cost, Time, Critical Business Objectives, and
Software. Test case & bug report will analyze to find out the defect distribution by
type and severity. Once complete the test cycle then test closure report & Test
metrics will be prepared
15
1.5 THE V SHAPED SOFTWARE LIFE CYCLE MODEL
The V shaped model is the modified form of the waterfall model with a special
focus on testing activities. The waterfall model allows us to start testing activities
after the completion of the implementation phase. This was popular when testing was
primarily validation oriented. Now, there is a shift in testing activities from validation
to verification where we want to review / inspect every activity of the software
development life cycle. We want to involve the testing persons from the requirement
analysis and specification phase itself. They will review the SRS document and
identify the weak areas, critical areas, ambiguous areas and misrepresented areas. This
will improve the quality of the SRS document and may further minimize the errors.
16
These verification activities are treated as error preventive exercises and are
applied at requirements analysis and specification phase, high level design phase,
detailed design phase and implementation phase. We not only want to improve the
quality of the end products at all phases by reviews, inspections and walkthroughs, but
also want to design test cases and test plans during these phases. The designing of test
cases after requirement analysis and specification phase, high level design phase,
detailed design phase and implementation phase may help us to improve the quality of
the final product and also reduce the cost and development time.
Graphical Representation :
The shape of the model is like the English letter ‘V’ and it emphasizes testing
activities in every phase. There are two parts of the software development life cycle in
this model i.e. development and testing and are shown in Figure 1.10. We want to
carry out development and testing activities in parallel and this model helps us to do
the same in order to reduce time and cost.
Errors are generated due to wrong logic, syntax, or loop that can impact the end-
user experience.
It is calculated by differentiating between the expected results and the actual
results.
It raises due to several reasons like design issues, coding issues, or system
specification issues and leads to issues in the application.
Fault/Defects
Sometimes due to certain factors such as Lack of resources or not following
proper steps Fault occurs in software which means that the logic was not
incorporated to handle the errors in the application. This is an undesirable situation,
but it mainly happens due to invalid documented steps or a lack of data definitions.
It is an unintended behavior by an application program.
It causes a warning in the program.
If a fault is left untreated it may lead to failure in the working of the deployed
code.
A minor fault in some cases may lead to high-end error.
There are several ways to prevent faults like adopting programming techniques,
development methodologies, peer review, and code analysis.
Failure
Failure is the accumulation of several defects that ultimately lead to Software
failure and results in the loss of information in critical modules thereby making the
system unresponsive. Generally, such situations happen very rarely because before
releasing a product all possible scenarios and test cases for the code are simulated.
Failure is detected by end-users once they face a particular issue in the software.
Failure can happen due to human errors or can also be caused intentionally in
the system by an individual.
It is a term that comes after the production stage of the software.
It can be identified in the application when the defective part is executed.
A simple diagram depicting Bug vs Defect vs Fault vs Failure:
18
1.7 SOFTWARE TESTING PRINCIPLES
Continuing with the major premise of this chapter, that the most important considerations
in software testing are issues of psychology, we can identify a set of vital testing
principles or guidelines.
19
correct result. One way of combating this is to encourage a detailed examination of all
output by precisely spelling out, in advance, the expected output of the program.
Therefore, a test case must consist of two components:
1. A description of the input data to the program.
2. A precise description of the correct output of the program for that set of input
data.
Principle 2: A programmer should avoid attempting to test his or her own program.
Any writer knows—or should know—that it’s a bad idea to attempt to edit or proofread
his or her own work. They know what the piece is supposed to say, hence may not
recognize when it says otherwise. And they really don’t want to find errors in their own
work. The same applies to software authors
Principle 4: Any testing process should include a thorough inspection of the results
of each test.
This is probably the most obvious principle, but again it is something that is often
overlooked. We’ve seen numerous experiments that show many subjects failed to detect
certain errors, even when symptoms of those errors were clearly observable on the output
listings. Put another way, errors that are found in later tests were often missed in the
results from earlier tests.
Principle 5: Test cases must be written for input conditions that are invalid and
unexpected, as well as for those that are valid and expected.
There is a natural tendency when testing a program to concentrate on the valid and
expected input conditions, to the neglect of the invalid and unexpected conditions.
20
paychecks is still an erroneous program if it also produces extra checks for nonexistent
employees, or if it overwrites the first record of the personnel file.
Principle 7: Avoid throwaway test cases unless the program is truly a throwaway
program.
This problem is seen most often with interactive systems to test programs. A
common practice is to sit at a terminal and invent test cases on the fly, and then send
these test cases through the program. The major issue is that test cases represent a
valuable investment that, in this environment, disappears after the testing has been
completed. Whenever the program has to be tested again (e.g., after correcting an error or
making an improvement), the test cases must be reinvented. Saving test cases and
running them again after changes to other components of the program is known as
regression testing
Principle 8: Do not plan a testing effort under the tacit assumption that no errors
will be found.
This is a mistake project managers often make and is a sign of the use of the
incorrect definition of testing—that is, the assumption that testing is the process of
showing that the program functions correctly. Once again, the definition of testing is the
process of executing a program with the intent of finding errors.
21
forms to be filled out, and so on. Here, after a short summary of the general
procedure, we will focus on the actual error-detection techniques.
Inspection Team: An inspection team usually consists of four people. The first
of the four plays the role of moderator, which in this context is tantamount to that of
a quality-control engineer.
22
relationship, in favor of a cooperative, team approach to projects, can lead to more
efficient and reliable program development
Finally, the inspection process is a way of identifying early the most error-
prone sections of the program, helping to focus attention more directly on these
sections during the computer-based testing processes
23
unit A and a unit B is called ‘stub’. The complete additional source code which is
written for the design of stub and driver is called scaffolding.
24
.
A design with high coupling may have more errors. Loose coupling minimizes
the interdependence, and some of the steps to minimize coupling are given as:
A good design should have low coupling and thus interfaces become very
important. When interfaces are important, their testing will also be important. In
integration testing, we focus on the issues related to interfaces amongst units. There
are several integration strategies that really have little basis in a rational methodology
and are given in Figure 8.4.
Top down integration starts from the main unit and keeps on adding all called
units of the next level. This portion should be tested thoroughly by focusing on
interface issues. After completion of integration testing at this level, add the next level
of units and so on till we reach the lowest level units (leaf units). There will not be
any requirement of drivers and only stubs will be designed.
25
In bottom-up integration, we start from the bottom, (i.e. from leaf units) and
keep on adding upper level units till we reach the top (i.e. root node). There will not
be any need of stubs.
A sandwich strategy runs from top and bottom concurrently, depending upon
the availability of units and may meet somewhere in the middle.
26
1.9.3 System Testing
We perform system testing after the completion of unit and integration testing.
We test complete software along with its expected environment. We generally use
functional testing techniques, although a few structural testing techniques may also be
used. A system is defined as a combination of the software, hardware and other
associated parts that together provide product features and solutions. System testing
ensures that each system function works as expected and it also tests for non-
functional requirements like performance, security, reliability, stress, load, etc. This is
the only phase of testing which tests both functional and non-functional requirements
of the system.
A team of the testing persons does the system testing under the supervision of a
test team leader. We also review all associated documents and manuals of the software.
This verification activity is equally important and may improve the quality of the final
product. Utmost care should be taken for the defects found during the system testing
phase. Progress of system testing also builds confidence in the development team as
this is the first phase in which the complete product is tested with a specific focus on
the customer’s expectations. After the completion of this phase, customers are invited
to test the software.
Testing aspects Functional testing Non-functional testing
Involves Product features Quality factors
and
functionality
Tests Product behavior Behavior and experience
Result conclusion Simple steps written to Huge data collectedand
check analyzed
expected results
Results varies due to Product implementation Product
implementation,
resources and
configurations
Testing focus Defect detection Qualification of product
Knowledge required Product and domain Product, domain,
design,
architecture, statistical
skills
Failures normally due to Code Architecture, design and
code
Testing phase Unit, component, system
integration,
system
27
28