Unit 4.1
Unit 4.1
1
What is Testing?
"Testing is the process of executing a program' with the intent of finding errors".
This may Include planning, designing of test cases, execution of program with
test cases interpretation of the outcome and finally collection and management
of data.
It is a very expensive process and consumes one third to one-half of the cost of
a typical development project.
No one would think of allowing automatic pilot software into service without the most
rigorous testing.
In so-called life critical systems, economics must not be the prime consideration while
deciding whether a product should be released to a customer.
It is not possible to test the software for all possible combinations of input cases.
Testing therefore continues to the point where it is considered that the costs of the
testing processes significantly outweigh the returns.
Hence, when to release the soft-ware in the market, is a very important decision.
Who should do the Testing?
The testing requires the developers to find errors from their software. It is very
difficult for software developer to point out errors from own creations.
Therefore, most of the times, testing persons are different from development
persons for the overall benefit of the system.
Hence, complete testing is just not possible, although, we may wish to do so.
Another dimension is to execute all possible paths of the program.
A program path can be traced through the code from the start of the program to
program termination.
Two paths differ if the program executes different statements in each, or executes
the same statements but different order. A program may have many paths.
Error, Mistake, Bug, Fault and Failure
People make errors. A good synonym is mistake. This may be a syntax error or
misunderstanding of specifications. Sometimes, there are logical errors. When
developers make mistakes while coding, we call these mistakes "bugs".
Errors propagate from one phase to another with higher severity. A requirement
error may be magnified during design , and amplified still more during coding. If
it could not be detected prior to release it may have serious implications in the
field. An error may lead to one or more faults.
A particular fault may cause different failures, depending on how it has been
exercised.
Test, Test case and Test Suite
Test and Test case terms are used interchangeably. In practice, both are same
and are treated as synonyms.
Inputs are of two types: pre conditions (circumstances that hold prior to test
case execution) and the actual inputs that are identified by some testing
methods.
Expected outputs are also of two types: post conditions and actual outputs.
During testing, we set necessary preconditions, give required inputs to program,
and compare the observed output with expected output to know the outcome
of a test case.
If expected and observed outputs are different, then, there is a failure and it
must be recorded properly in order to identify the cause of failure.
If both are same, then, there is no failure and program behaved in the expected
manner.
The test case designer's main objective is to identify good test cases.
The template for a typical test case is given in Fig. 8.2.
Test cases are valuable and useful—at least as valuable as source code. They
need to be developed, reviewed, used, managed, and saved. The set of test
cases is called a test suite.
We may have a test suite of all possible test case. We may have a test suite of
effective/good test cases. Hence any combination of test cases may generate a
test suite.
Alpha, Beta and Acceptance Testing
Customer involvement is required before delivering the final product. The above
mentioned three terms are related to customer's involvement in testing but have
different meanings.
Acceptance testing
This term is used when the software is developed for a specific customer. A series of tests are
conducted to enable the customer to validate all requirements.
These tests are conducted by the end user/customer and may range from adhoc tests to well
planned systematic series of tests.
The discovered error will be fixed and better quality software will be delivered to the
customer.
The alpha tests are conducted at the developer's site by a customer. These test's
are conducted in a controlled environment. Alpha testing may be started when
formal testing process is near completion.
The beta tests are conducted by the customers/end users at their sites. Unlike
alpha testing, developer is not present here. Beta testing is conducted in a real
environment that cannot be controlled by the developer. Customers are expected
to report failures, if any, to the company.
After receiving such failure reports, developers modify the code and fix the bug
and prepare the product for final release.
Most of the companies are following this practice firstly, they send the beta
release of their product for few months.
Many potential customers will use the product and may sent their views about
the product.
FUNCTIONAL TESTING
Functional testing refers to testing, which involves only observation of the
output for certain input values.
Here, we are interested in functionality rather than internal structure of the code.
For example, most people successfully operate automobiles with only black box knowledge.
Following are main techniques to black box testing
• Equivalence Class Partitioning
• Boundary Value Analysis
• Cause Effect Graphs.
1.1Boundary Value Analysis
Experience shows that test cases that are close to boundary conditions have a
higher chances of detecting an error.
Here boundary condition means, an input value may be on the boundary, just
below the boundary (upper side) or just above the boundary (lower side).
Hence both the inputs x and y are bounded by two intervals [a, b] and [c, d]
respectively.
For input x, we may design test cases with values a and b, just above a and also
just below b.
Similarly for input y, we may have values c and d, just above c and also just
below d.
These test cases will have more chances to detect an error.
Any point within the inner rectangle is a legitimate input to the program.
For input x, we may design test cases with values a and b, just above a and also
just below b.
Similarly for input y, we may have values c and d, just above c and also just
below d.
The basic idea of boundary value analysis is to use input variable values at their
minimum, just above minimum, a nominal value, just below their maximum and
at their maximum.
Thus, boundary value analysis test cases are obtained by holding the values of all
but one variable at their nominal values and letting that variable assume its
extreme values.
The boundary value analysis test cases for our program with two inputs variables
(x and y) that may have any value from 100-300 are:
(200, 100), (200, 101), (200, 200), (200, 299), (200, 300), (100, 200), (101, 200),
(299, 200) and (300, 200).
This input domain is shown in Fig. 8.5. Each dot represent a test case and inner
rectangle is the domain of legitimate inputs.
Here, we would like to see, what happens when the extreme values are exceeded
with a value slightly greater than the maxi-mum and a value slightly less than
minimum.
This extended form of boundary value analysis is called robustness testing and
shown in Fig. 8.6.
There are four additional test cases which are outside the legitimate input domain.
Hence total test cases in robustness testing are 6n + 1, where n is the number of
input variables.
So, 13 test cases are:
(200, 99), (200, 100), (200, 101), (200, 200), (200, 299), (200, 300), (200, 301), (99,
200), (100, 200), (101, 200), (299, 200), (300, 200), (301, 200).
1.3 Worst-case testing
If we like to see what happens when more than one variable has -an extreme value.
It is more thorough in the sense that boundary value test cases are a proper subset of
worst case test cases.
Worst case testing for a function of n variables generates 5n test cases as opposed to 4n
+ 1 test cases for boundary value analysis.
Our two variable example will have 52 = 25 test cases and are given in Table 8.1.
Boundary value analysis works well for the programs with independent input
values.
This technique does not make sense for Boolean variables where extreme values
are TRUE and FALSE, but no clear choice is available for other values like
nominal, just above boundary and just below boundary.
1.4 Equivalence Class Testing
In this method, input domain of a program is partitioned into a finite number of
equivalence classes such that one can reasonably assume that the test of a
representative value of each class is equivalent to a test of any other value.
That is, if one test case in a class detects an error, all other test cases in the class
would be expected to find same error.
Conversely, if a test case did not detect an error, we would expect that no other
test cases in the class would find an error.
Two steps are required in implementing this method:
Then a test case is written for each invalid equivalence class so that
no test contains more than one invalid class. This is to ensure that no
two invalid classes mask each other.
The idea is to choose at least one element from each equivalent class.
In the triangle problem we would certainly have a test case for equivalent
triangle, and we may take (50, 50, 50) as inputs for a test case.
If we do this, we would not expect to learn much from test cases such as (40, 40,
40) and (100, 100, 100).
We should test different types of invalid inputs in order to get more errors.
As an example, for a program that is supposed to accept any number between 1 and
99, there are at least four equivalence classes from input side.
Most of the time, equivalence class testing defines classes of the input domain.
However, equivalence classes should also be defined for output domain. Hence, we
should design equivalence classes based on input and output domains.
Cause Effect Graphing Technique
One weakness of boundary value analysis and equivalence partitioning is that
these do not explore combinations of input circumstances.
Causes and effects are identified by reading the specification word by word and
underlining words or phrases that describe causes and effects. Each cause and
effect is assigned a unique number.
2. The semantic content of the specification is analyzed and transformed into a
Boolean graph linking the causes and effects. This is the cause effect graph.
5. The columns in the decision table are converted into test cases. The basic
notation for the graph is shown in Fig. 8.8.
Think of each node as having the value 0 or 1; 0 represents the 'absent state' and
1 represents the present state. The identity function states that if c1 is 1, e1 is 1;
else e1 is 0.