ASE Coding and Testing
ASE Coding and Testing
Introduction
Testing: The aim of the testing process is to identify all defects existing in a
software product. It is true that testing does expose many defects existing in
a software product and therefore, testing provides a practical way of
reducing defects in a system and increasing the user’s confidence in a
developed system.
Coding: The main objective of the coding phase is to transform the design of
the system as given by its module specification into a high-level language
code and then to unit test this code. During the coding phase, different
modules identified in the design document are coded according to the
module specifications as specified in the design document.
Normally, good software development organizations adhere to some well-
defined and standard style of coding called coding standards. The reasons for
adhering to a standard coding style are the following:
► It gives a uniform appearance to the codes written by different
programmers.
► It enhances code understanding.
► It encourages good programming practices.
After a module has been coded, usually code inspection and code walk-
throughs are carried out to ensure that coding standards are followed and to
detect as many errors as possible before testing.
Code Walk-Throughs
A code walk-through is an informal technique for analysis of the code.
► The team performing a code walk-through should not be either too big or
too small. Ideally, it should consist of between three to seven members.
► Discussions should be focused on the discovery of errors and not on how
To fix the discovered errors.
Code Inspections
In contrast to code walk-throughs, code inspections aim explicitly at the
discovery of commonly made mistakes. Most software development
companies collect statistics to identify the type of errors most frequently
committed. Such a list of commonly committed errors can be used during
code inspections to keep a look-out for possible errors.
The following is a list of some classical programming errors which can be
looked for during code inspections:
► Use of uninitialized variables.
► Jumps into loops.
► Non terminating loops.
► Incompatible assignment.
► Array indices out of bounds.
► Improper storage allocation and deallocation.
► Mismatches between actual and formal parameters in procedure calls.
► Use of incorrect logical operators or incorrect precedence among
operators.
► Improper modifications of loop variables.
► Comparison of equality of floating point values, etc.
► Adherence to coding standards is also checked during code inspections.
Software Documentation
While developing a software product, in addition to executable files and the
source code, various kinds of other documents such as user’s manual, SRS
document, design document, test document, installation manual etc., are
also developed. All these documents are a vital part of any good software
development practice. Good documents enhance understandability and
maintainability of a software product.
Different types of software documentation can be broadly classified into:
► Internal documentation.
► External documentation (supporting documents).
Driver Module
Stub Module
int compute_gcd(x, y)
int x, y;
{ Why is not branch coverage the same
while (x! = y) thing as code coverage?
{ Consider an if with no else, or a switch
if (x>y) then with no default case.
x= x – y; Code coverage can be achieved without
else y= y – x; achieving branch coverage.
}
return (x);
}
By choosing the test set {(x=3, y=3); (x=4, y=3); (x=3, y=4)}, we exercise
the program such that all statements are executed at least once.
Branch Coverage
For Euclid’s GCD computation algorithm, the test cases for branch coverage
can be {(x=3, y=3), (x=3, y=2), (x=4, y=3), (x=3, y=4)}.
Condition Coverage
In this structural testing, test cases are designed such that each component
of a condition of a composite conditional expression is given both true and
false values. For example, in the conditional expression ((c1 and c2) or C3),
c1, c2 and c3 are each exercised at least once.
The data flow-based testing method selects the test paths of a program
according to the locations of the definitions and uses of different variables in
a program.
Mutation Testing
The goal of testing is to make sure that during the course of testing, each
mutant produces an output different from the output of the original source
program.
Debugging and Integration Testing
Debugging Guidelines
The following are some general guidelines for effective debugging:
A program analysis tool usually means an automated tool that takes the
source code of a program as input and produces reports regarding several
important characteristics of the program such as the size, complexity,
adequacy of commenting, adherence to programming standards, etc. Also,
some program analysis tools produce reports regarding the adequacy of the
test cases. There are essentially two categories of program analysis tools:
► Static analysis tools.
► Dynamic analysis tools.
Static analysis tools assess and portray the properties of a software product
without executing it. Typically, static analysis tools analyze some structural
representation of a program to arrive at certain analytical conclusions. The
structural properties that are usually analyzed are:
► Whether the coding standards have been adhered to?
► Certain programming errors such as uninitialized variables, mismatch
between actual and formal parameters, variables that are declared but
never used, etc.
A major practical limitation of the static analysis tools lies in handling
dynamic evaluation of memory references at run-time.
Static analysis tools often summarize the results of analysis of every function
in a polar chart known as Kiviat Chart. A Kiviat Chart typically shows the
analyzed values for cyclomatic complexity, number of source lines,
percentage of comment lines, Halstead’s metrics, etc.
► Big-bang approach
► Top-down approach
► Bottom-up approach
► Mixed approach
Big-Bang Approach
Advantages:
Convenient for small systems.
Disadvantages:
Fault Localization is difficult.
Given the sheer number of interfaces that need to be tested in this
approach, some interfaces link to be tested could be missed easily.
Since the Integration testing can commence only after "all" the
modules are designed, the testing team will have less time for
execution in the testing phase.
Since all modules are tested at once, high-risk critical modules are
not isolated and tested on priority. Peripheral modules which deal with
user interfaces are also not isolated and tested on priority.
Bottom-Up Approach
Advantages:
Fault localization is easier.
No time is wasted waiting for all modules to be developed unlike
Big-bang approach.
Disadvantages:
Critical modules (at the top level of software architecture) which
control the flow of application are tested last and may be prone to
defects.
An early prototype is not possible.
Bottom Up Testing
Top-Down Approach
Advantages:
Fault Localization is easier.
Possibility to obtain an early prototype.
Critical Modules are tested on priority; major design flaws could be found and
fixed first.
Disadvantages:
Needs many Stubs.
Modules at a lower level are tested inadequately.
Stress Testing
Stress testing is also known as endurance testing. Stress test are black-box
tests which are designed to impose a range of abnormal and even illegal
input conditions so as to stress the capabilities of the software. Input data
volume, input data rate, processing time, utilization of memory, etc. are
tested beyond the designed capacity.
Stress testing usually involves an element of time and size, such as the
number of records transferred per unit time, the maximum number of users
active at any time, input data size, etc. Therefore, stress testing may not be
applicable to many types of systems.
Error Seeding
Error seeding as the name implies, seeds the code with some known errors.
In other words, some artificial errors are introduced into the program. The
number of these seeded errors detected in the course of the standard testing
procedure is determined. These values in conjunction with the number of
unseeded errors detected can be used to predict:
► The number of errors remaining in the product.
► The effectiveness of the testing strategy.
Let N be the total number of defects in the system and let n of these defects
be found by testing.
Let S be the total number of seeded defects, and let s of these defects be
found during testing.
Therefore, n/N=s/S or N = S * n / s
Remaining defects = N – n = n * ( ( S – s ) / s)
General Issues Associated with Testing
► Testing documentation.
► Regression Testing.
Regression Testing
Test Plan
A document describing the scope, approach, resources, and schedule
of intended testing activities. It identifies test items, the features to be
tested, the testing tasks, who will do each task, and any risks requiring
contingency planning.
We observed that the system test suite is designed based on the SRS
document. The two major types of system testing are functionality
testing and performance testing. The functionality test cases are
designed based on the functional requirements and the performance test
cases are design to test the compliance of the system to test the non-
functional requirements documented in the SRS document.
*****