Module II notes (6)
Module II notes (6)
MODULE 2
BASIC DEFINITIONS
Error
People make errors. A good synonym is “mistake”. When people make
mistakes while coding, we call these mistakes “bugs”.
Errors tend to propagate; a requirements error may be magnified during
design, and amplified still more during coding
Fault
A fault is the result of an error. It is more precise to say that a fault is the
representation of an error
It is the representation of an error, where representation is the mode of
expression, such as narrative text, dataflow diagrams, hierarchy charts,
source code, and so on.
“Defect” is a good synonym for fault; so is “bug”.
Faults can be elusive.
There are 2 types of faults: faults of commission and faults of omission.
A fault of commission occurs when we enter something into a
representation that is incorrect.
Faults of omission occur when we fail to enter correct information. Faults
of omission are more difficult to detect and resolve.
Failure
Incident
An incident is the symptom(s) associated with a failure that alerts the user
to the occurrence of a failure.
Test
There are three opportunities for errors to be made, resulting in faults that
propagate through the remainder of the development.
One prominent tester summarizes this life cycle as follows: the first three
phases are “Putting Bugs IN”, the testing phase is Finding Bugs, and the last three
phases are “Getting Bugs OUT”.
The Fault Resolution step is another opportunity for errors (and new faults).
When a “fix” causes formerly correct software to misbehave, the fix is deficient.
It is clear from the diagram that the test cases occupy a central position in
testing. The process of testing can be subdivided into separate steps: test
planning, test case development, running test cases, and evaluating test results.
INSIGHTS FROM A VENN DIAGRAM
Testing is fundamentally concerned with behavior; and behavior is
orthogonal to the structural view common to software (and system) developers.
A quick differentiation is that the structural view focuses on “what it is” and
the behavioral view considers “what it does”.
One of the continuing sources of difficulty for testers is that the base
documents are usually written by and for developers, and therefore the emphasis
is on structural, rather than behavioral, information.
A simple Venn diagram can be developed which clarifies several nagging
questions about testing.
2 and 5), specified behaviors that are tested (regions 1 and 4), and test cases that
correspond to unspecified behaviors (regions 3 and 7). Similarly, there may be
programmed behaviors that are not tested (regions 2 and 6), programmed
behaviors that are tested (regions 1 and 3), and test cases that correspond to
unprogrammed behaviors (regions 4 and 7). Each of these regions is important. If
there are specified behaviors for which there are no test cases, the testing is
necessarily incomplete
INPUT OUTPUT
- Notice that, for both methods, the set of test cases is completely
contained within the setof specified behavior. Since functional methods are based
on the specified behavior, it is hard toimagine these methods identifying
behaviors that are not specified
2) Structural Testing
Structural testing is the other fundamental approach to test case
identification.
It is sometimes called White Box (or Clear Box) Testing.
The essential difference is that the implementation(of the Black Box) is
known and used to identify test cases. Being able to “see inside” the black
boxallows the tester to identify test cases based on how the function is actually
implemented.
With linear graph theory concepts, the testercan rigorously describe exactly
what is being tested. Because of its strong theoretical basis,structural testing
lends itself to the definition and use of test coverage metrics.
Specification Program
Specification Program
Above Figure shows the results of test cases identified by two structural methods.
- Method A identifies a larger set of test cases than does Method B.
ERROR AND FAULT TAXONOMIES
Faults can be classified in several ways: the development phase where
thecorresponding error occurred, the consequences of corresponding failures,
difficulty to resolve, riskof no resolution, and so on.
LEVELS OF TESTING
Levels oftesting echo the levels of abstraction found in the Waterfall Model
of the software
development life cycle. It is useful for testing as a means of identifying distinct
levels of testing,and for clarifying the objectives that pertain to each level.
Static testing is carried out without executing the application under test.
This is in contrast to dynamic testing that requires one or more executions
of the application under test.
It is useful in that it may lead to the discovery of faults in the application,
ambiguities and errors in the requirements and other application-related
document, at a relatively low cost,
This is especially so when dynamic testing expensive.
Static testing is complementary to dynamic testing.
This is carried out by an individual who did not write the code or by a team
of individuals.
The test team responsible for static testing has access to requirements
document, application, and all associated documents such as design
document and user manual.
Team also has access to one or more static testing tools.
A static testing tool takes the application code as input and generates a
variety of data useful in the test process.
Walkthroughs
Walkthroughs and inspections are an integral part of static testing.
Walkthrough are an integral part of static testing.
Walkthrough is an informal process to review any application-related
document.
Inspection plan:
i. statement of purpose
ii. work product to be inspected this includes code and associated documents
needed for inspection.
iii. team formation, roles, and tasks to be performed.
(a) CFG clearly shows that the definition of x at block 1 is used at block-3
but not at block 5.In fact the definition of x at block 1 is considered killed
due to its redefinition at block 4.
(b) CFG indicates the use of variable y in the block 3.If y is not defined
along the path from start to block 3,then there is a data-flow error as a
variable is used before it is defined. Several such errors can be detected by
static analysis tools. ->compute complexity metrics, used as a parameter in
deciding which modules to inspect first.
GENERALIZED PSEUDOCODE
Pseudocodeproides a “language neutral” way to express program
source code.
The given version is based on Visual basic and has constructs at 2
level
Unit component: Units can be interpreted either as
traditional components( procedures and functions) or as
object oriented components( classes and objects)
Items in angle brackets indicate language elements that can be used at the
identified position
EXAMPLES
1) TRIANGLE PROBLEM
Problem Statement
The Triangle Program accepts three integers as input; these are taken to be sides
of a triangle. The
output of the program is the type of triangle determined by the three sides:
Equilateral, Isosceles,
Scalene, or NotATriangle.
Improved version:
Triangle accepts 3 integers a, b, and c as input. It must satisfy the following
conditions:
c1.1 ≤a ≤ 200 c4. a < b + c
c2.1 ≤ b ≤ 200 c5. b < a + c
c3.1 ≤ c ≤ 200 c6. c < a +b
If an input value fails any of conditions c1, c2, or c3, the program notes this with
anoutput message, for example, “Value of b is not in the range of permitted
values.” If values of a, b, and c satisfy conditions c1, c2, and c3, one of four
mutually exclusive outputs is given:
1. If all three sides are equal, the program output is Equilateral.
2. If exactly one pair of sides is equal, the program output is Isosceles.
3. If no pair of sides is equal, the program output is Scalene.
4. If any of conditions c4, c5, and c6 is not met, the program output is
NotATriangle.
i. Traditional Implementation
The flowchart for this implementation appears in Figure 2.1. The flowchart
box numbes correspond to comment numbers in the (FORTRAN-like) TurboPascal
program given next.
c2:1 ≤ day ≤ 31
c3: 1 ≤ year ≤ 2012
Since a year is365.2422 days long, leap years are used for the “extra day”
problem.
If we declared a leap year every fourth year, there would be a slight error. The
Gregorian Calendar resolves this by adjusting leap years on century years.
Century years are leap years only if they are multiplesof 400, so 1992,
1996, and 2000 are leap years, while the year 1900 is acommon year.
Problem Statement
A rifle salesperson in the former Arizona Territory sold rifle locks,stocks, and
barrels made by a gunsmith in Missouri. Locks cost $45,stocks cost $30, and
barrels cost $25. The salesperson had to sell atleast one complete rifle per
month, and production limits were suchthat the most the salesperson could
sell in a month was 70 locks, 80stocks, and 90 barrels. After each town visit,
the salesperson sent atelegram to the Missouri gunsmith with the number of
locks, stocks, and barrels sold in that town. At the end of a month, the
salespersonsent a very short telegram showing –1 locks sold. The gunsmith
thenknew the sales for the month were complete and computed
thesalesperson’s commission as follows: 10% on sales up to (andincluding)
$1000, 15% on the next $800, and 20% on any sales inexcess of $1800. The
commission program produced a monthly salesreport that gave the total
number of locks, stocks, and barrels sold, thesalesperson’s total dollar sales,
and, finally, the commission
Implementation
The SATM system communicates with bank customers via the fifteen
screens shown in Figure 2.4. Using a terminal with features as shown in figure
below, SATM customers can select any of threetransaction types: deposits,
withdrawals, and balance inquiries, and these can be done on two types of
accounts, checking and savings.
When a bank customer arrives at an SATM station, screen 1 is displayed.
The bank customer accesses the SATM system with a plastic card encoded with a
Personal Account Number (PAN), which is a key to an internal customer account
file, containing, among other things, the customer’s name and account
information. If the customer’s PAN matches the information in the customer
account file, the system presents screen 2
to the customer. If the customer’s PAN is
not found, screen 4 is displayed, and the
card is kept. At screen 2, the customer is
prompted to enter his/her Personal
Identification Number (PIN). If the PIN is
correct (i.e., matches the information in
the customer account file), the system
displays screen 5; otherwise, screen 3 is displayed. The customer has three
chances to get the PIN correct; after three failures, screen 4 is displayed, and the
card is kept.
If balance is requested, the system checks the local ATM file for any
unposted transactions, and reconciles these with the beginning balance for that
day from the customer account file. Screen 14 is then displayed.
If deposit is requested, the status of the Deposit Envelope slot is
determined from a field in the Terminal Control File. If no problem is known, the
system displays screen 7 to get thetransaction amount. If there is a problem with
the deposit envelope slot, the system displays screen 12. Once the deposit
amount has been entered, the system displays screen 13, accepts the deposit
envelope, and processes the deposit. The deposit amount is entered as an
unposted amount in the local ATM file, and the count of deposits per month is
incremented. Both of these (and otherinformation) are processed by the Master
ATM (centralized) system once per day. The system then displays screen 14.
If withdrawal is requested, the system checks the status (jammed or free)
of the withdrawal chute in the Terminal Control File. If jammed, screen 10 is
displayed, otherwise, screen7 is displayed so the customer can enter the
withdrawal amount. Once the withdrawal amount isentered, the system checks
the Terminal Status File to see if it has enough money to dispense. If it does not,
screen 9 is displayed; otherwise the withdrawal is processed. The system checks
the customer balance (as described in the Balance request transaction), and if
there are insufficient funds, screen 8 is displayed. If the account balance is
sufficient, screen 11 is displayed, and the money is dispensed. The withdrawal
amount is written to the unposted local ATM file, and the count of withdrawals
per month in incremented. The balance is printed on the transaction receipt as it
is for a balance request transaction. After the cash has been removed, the system
displays screen 14.
When the No button is pressed in screens 10, 12, or 14, the system
presents screen 15 and returns the customer’s ATM card. Once the card is
removed from the card slot, screen 1 is displayed. When the Yes button is pressed
in screens 10, 12, or 14, the system presents screen 5 so the customer can select
additional transactions.