Unit-III Code Examination
Unit-III Code Examination
• 4.They may not necessarily understand the details of the code, but
by listening to the review comments they can identify feature areas
that sound troublesome or bug-prone.
Formal Review
A formal review can range from a simple meeting between two
programmers to a detailed, rigorous inspection of the code.
There are four essential elements to a formal review
• 1. Identify Problems: - The goal of the review is to find problems with the
software—not just items that are wrong, but missing items as well. All criticism
should be directed at the code, not the person who created it.
• 2. Follow Rules: - A fixed set of rules should be followed. Set the amount of code
to be reviewed (usually a couple hundred lines), how much time will be spent (a
couple hours), what can be commented on, and so on.
• 4. Write a Report: - The review group must produce a written report summarizing
the results of the review and make that report available to the rest of the product
development team.—how many problems were found, where they were found,
and so on.
Type of Reviews
1. Peer Reviews
2. Walkthrough
3. Inspection
• Peer Reviews
1. The easiest way to get team members together and doing their first formal
reviews of the software is through peer reviews, the least formal method.
2. Peer reviews are often held with just the programmer who wrote the code and
one or two other programmers or testers acting as reviewers.
3. Small group simply reviews the code together and looks for problems and
oversights.
4. To assure that the review is highly effective all the participants need to make sure
that the four key elements of a formal review are in place: Look for problems,
follow rules, prepare for the review, and write a report.
Walkthrough
• Walkthroughs are the next step up in formality from peer reviews.
• In a walkthrough, the programmer who wrote the code formally
presents (walks through) it to a small group of five or so other
programmers and testers.
• Control Flow Errors : - Control flow errors are the result of loops and
other control constructs in the language not behaving as expected.
Individual pieces of code are built up and tested separately, and then integrated
and tested again.
Data Coverage
1. The logical approach is to divide the code just as you did in black-box
testing into its data and its states (or program flow).
2. By looking at the software from the same perspective, you can more
easily map the white-box information you gain to the black-box cases
you’ve already written.
3. Consider the data first. Data includes all the variables, constants, arrays,
data structures, keyboard and mouse input, files and screen input and
output, and I/O to other devices such as modems, networks, and so on.
2. E.g. An operating system running low on RAM may start moving data to
temporary storage on the hard drive. This sub-boundary may not even
be fixed. It may change depending on how much space remains on the
disk.
3. If you perform white-box testing, you need to examine the code
carefully to look for sub-boundary conditions and create test cases that
will exercise them.
4. Ask the programmer who wrote the code if he/she knows about any of
these situations and pay special attention to internal tables of data
because they’re especially prone to sub-boundary conditions.
Formula and Equations
1. Very often, formulas and equations are buried deep in the code and
their presence or effect isn’t always obvious from the outside.
2. A financial program that computes compound interest will definitely
have this formula somewhere in the software:
3. A=P(1+r/n)^nt
where
• P = principal amount
• r = annual interest rate
• n = number of times the interest is compounded per year
• t = number of years
• A = amount after time t
4. A good black-box tester would hopefully choose a test case of n=0, but
a white-box tester, after seeing the formula in the code, would know to
try n=0 because that would cause the formula to blow up with a divide-
by-zero error.
Error Forcing
• It aims to test all the branches or edges at least once in the test
suite or to test each branch from a decision point at least once.
5. Condition Coverage:
• It aims to test individual conditions with possible different
combination of Boolean input for the expression.
2. They do overlap, however, in the area of isolating where and why the bug
occurs.
3. Software tester, narrow down the problem to the simplest test case that
demonstrates the bug. So, it includes information about what lines of code look
suspicious.
• The programmer who does the debugging picks the process up from there,
determines exactly what is causing the bug, and attempts to fix it.
4. While performing this low-level testing, both will use many of the same tools.
• If the program is compiled, you will use the same compiler but possibly with
different settings to enable better error detection.
• E.g. using a code-level debugger to single-step through the program, watch
variables, and set break conditions, and so on.
Thank You
S/W Testing Notes edited and compiled by Prof. Mohan
S. Khedkar