Final Module 5 Soften GG
Final Module 5 Soften GG
Final Module 5 Soften GG
LEARNING MODULE
in
CpE 106
SOFTWARE ENGINEERING
FINAL COVERAGE
Module 5
TOPICS
5.1 Software Coding
5.2 Software Testing Fundamentals
5.3 Levels of Testing
5.4 White box and Black box Testing
OBJECTIVES: Upon completion of this module, the student should be able to:
Explain the importance of implementation and testing in
software development.
Determine whether the observed behavior conforms to the
expected behavior.
Elaborate different levels of testing.
Distinguish white-box and black-box testing.
Categorize the different testing techniques and distinguish
their differences.
LEARNING ACTIVITIES:
During implementation stage, each of the components from the design is realized as
a program unit. Each unit then must be either verified or tested against its
specification
obtained in the design stage. This process is as depicted in Figure 5.1. Then the
individual program units representing the components of the system are combined
and tested as a whole to ensure that the software requirements have been met.
When the developers are satisfied with the product, it is then tested by the client
(acceptance testing). This phase ends when the product is accepted by the client.
Coding
During coding the focus is on developing programs that are easy to read and
understand and not simply on developing programs that are simple to write. Coding
can be subject to company-wide standards that may define the entire layout of
programs, such as headers for comments in every unit, naming conventions for
variables, classes and functions, the maximum number of lines in each component,
and other aspects of standardization. Structured programming helps the
understandability of programs. The goal of structured programming is to linearize the
control flow in the program. Single entry-single exit constructs should be used. The
constructs include selection (if-then-else) and iteration (while, repeat-unit).:
Structured Programming
Structured programs have the single-entry, single-exit property. This feature helps in
reducing the number of paths for flow of control. If there are arbitrary paths for the
flow of control, the program will be difficult to read, understand, debug, and maintain.
The static structure is the structure of the text of the program, which is usually just a
linear organization of statements of the program.
Both static and dynamic structures are the sequence of statements. The only
difference is that the sequence of statements in a static structure is fixed, whereas in
a dynamic structure it is not fixed. That means the dynamic sequence of statements
can change from execution to execution. The static structure of a program can be
easily understood. The dynamic structure of a program can be easily seen at the
time of execution.
All structured program design methods are based upon the two fundamental
principles
The second principle of structured program design is that any program can be
constructed using only three structured control constructs. The constructs selection,
iterations, and sequence are shown in Figure 5.2 (a, b, c, d). Any program
independent of the technology platform can be written using these constructs, i.e.,
selection, repetition, sequence. These structures are the basis of structured
programming.
It is very convenient to put logic systematically into the program. Due to the ease of
handling complex logic, the user, reader, and programmer understand the program
easily.
It is easy to verify, conduct reviews, and test the structured programs in an orderly
manner. If errors are found, they are easy to locate and correct.
The goal of the coding phase is to translate the design of the system into code in a
given programming language. In this phase the aim is to implement the design in the
best possible manner. This phase affects both testing and maintenance phases.
Well-written code can reduce the testing and maintenance effort.
5.2 SOFTWARE TESTING FUNDAMENTALS
Testing Principles
The purpose is to discover possible defects or flaws that cause the system to not
function according to customer requirements.
After finishing the requirements analysis process the test planning can start. Detailed
Test cases can start as soon as the design model ends.
Simple test using Pareto principle argues that 80 percent of all faults discovered
during the testing phase can affect 20 percent of all program components. The
problem at this stage is to isolate these components suspected by testing the same.
Testing should begin “in the small” and progress toward testing “in the large.”
The first tests planned and executed generally focuses on individual components. As
testing progresses, focus shifts in an attempt to find errors in integrated clusters of
components and ultimately in the entire system.
The software engineer who creates a system is not the best person to perform all
program tests. Especially for large projects an independent test group is required.
A strategy for software testing must accommodate low-level tests that are necessary
to verify that a small source-code segment has been correctly implemented as well
as high-level tests that validate major system functions against customer
requirements. A strategy must provide guidance for the practitioner and a set of
milestones for the manager.
Test Oracle
To test any program, we need to have a description of its expected behavior and a
method of determining whether the observed behavior conforms to the expected
behavior. For this we need a test oracle.
A test oracle is a mechanism, different from the program itself, which can be used to
check the correctness of the output of the program for the test cases.
Conceptually, we can consider testing a process in which the test cases are given to
the test oracle and the program under testing. The output of the two is then are
compared to determine if the program behaved correctly for the test cases, as shown
in Figure 5.3.
Test oracles are considered as human, they can conduct tests when there is a
discrepancy between the oracles and program results. First you need to check the
results produced by the oracles before declaring that there is a flaw in the program.
In the above illustrated picture, the test case data is according to the oracle and test
the program on that will be tested. The result of each of the end elements is
compared to determine if the Program behaved properly in accordance with the test
case.
The human oracles generally use the specifications of the program to decide what
the “correct” behavior of the program shouldn’t be. To help the oracle to determine
the correct behavior, it is important that the behavior of the system be
unambiguously specified and the specification itself shouldn’t be error-free.
There are three levels of testing, i.e., three individual modules in the entire software
system
Unit Testing
Integration Testing
System Testing
Unit Testing
In unit testing individual components are tested to ensure they operate correctly.
Focus on the verification effort. On the smallest unit of software design, each
component is tested independently without the other system components. There are
some reasons to perform test drives instead of a testing the whole product:
• The size of a simple module is small enough that you can allocate an error
fairly easily.
• The module is small enough that you can attempt to test it in some
demonstrably some exhaustive fashion.
Shuffling the interaction of multiple errors in widely different parts of the software are
eliminated.
In this case the module interface is tested to ensure that the information properly
flows inside and outside the program unit that is being tested. The local data
structure is examined to ensure that data stored temporarily maintains its integrity
during all steps of the execution algorithm. Conditions boundary tested are to ensure
that modules enquiries operate at the boundaries established to limit or restrict
processing. All independent paths through the control of structure are exercised to
ensure that all the statements have Been module executed at least once. And finally,
all errors handling paths are tested computation. According to Agarwal et al, 2010
there are some common errors in computation as follows:
Integration Testing
Another test level is the integration test. Integration test is a systematic technique for
constructing the program structure while at the same time conducting tests to
uncover errors associated with interfacing. In such a test, unit-tested modules are
combined into subsystems, which are then tested. The goal is to see if the modules
can be integrated properly.
The following are the various approaches used to perform integration testing:
Incremental Approach
The incremental approach means to first combine only two components together and
test them. Remove the errors if they are there, otherwise combine another
component to it and then test again, and so on until the whole system is developed.
Bottom-up integration
Bottom-up integration testing, as its name implies, begins construction and testing
with the components at the lowest level in the program structure. A bottom-up
integration strategy may be implemented with the following steps:
Drivers are removed and clusters are combined moving upward in the program
structure.
Regression Test
Regression testing is the activity that helps to ensure that changes (due to testing or
for other reasons) do not introduce unintended behavior or additional errors. The
regression test suite contains three different classes of test cases:
Smoke Test
Software components that have been translated into code are integrated into a
“build.” A build includes all data files, libraries, reusable modules, and engineered
components that are required to implement one or more product functions.
A series of tests is designed to expose errors that will keep the build from properly
performing its functions.
The build is integrated with other builds and the entire product (in its current form) is
smoke tested daily.
Integration Sandwich
Sandwich integration testing is the combination of both the top-down and bottom-up
approach. So, it is also called mixed integration testing. In it, the whole system is
divided into three layers, just like a sandwich: the target is in the middle and one
layer is above the target and one is below the target. The top-down approach is used
in the layer that is above the target and the bottom-up approach is used in the layer
that is below the target.
System Testing
In the system test, subsystems are integrated to make the whole system. The testing
process is concerned with finding errors that result from unanticipated interactions
between subsystems and system components. It is also concerned with validating
that the system meets its functional and nonfunctional requirements. There are three
essentially main kinds of system testing:
Alpha Testing
Alpha testing refers to the system testing carried out by the test team within the
development organization. The alpha test is conducted at the developer’s site by the
customer under the project team’s guidance. In this test, users test the software on
the development platform and point out errors for correction. However, the alpha
test, because a few users on the development platform conduct it, has limited ability
to expose errors and correct them. Alpha tests are conducted in a controlled
environment. It is a simulation of real-life usage. Once the alpha test is complete, the
software product is ready for transition to the customer site for implementation and
development.
Beta Testing
Beta tests are conducted at the customer site in an environment where the software
is exposed to a number of users. The developer may or may not be present while the
software is in use. So, beta testing is a real-life software experience without actual
implementation. In this test, end users record their observations, mistakes, errors,
and so on and report them periodically.
In a beta test, the user may suggest a modification, a major change, or a deviation.
The development has to examine the proposed change and put it into the change
management system for a smooth change from just developed software to a revised,
better software. It is standard practice to put all such changes in subsequent version
releases.
Acceptance Test
Each level in software testing has its importance which provides a means of
eliminating errors from early stages. In unit testing individual components are tested
to ensure that they operate correctly. In integration testing, many unit-tested modules
are combined into subsystems which are then tested. In system testing, subsystems
are integrated to make up the whole system and then tested.
In white-box testing, test cases are selected on the basis of examination of the code,
rather than the specifications. White-box testing is illustrated in Figure 5.5.
Using white-box testing methods the software engineer can test cases that:
• Guarantee that all independent paths within a module have been exercised at
least once.
• Exercise all logical decision on their true and false sides.
• Exercise all loops at their boundaries.
• Exercise internal data structures to ensure their validity.
• To ascertain whether input data structure specifications are tested and then
used for other processing.
Functional/Black-Box Testing
In functional testing the structure of the program is not considered. Test cases are
decided on the basis of the requirements or specifications of the program or module
and the internals of the module or the program are not considered for selection of
test cases.
Functional testing refers to testing that involves only observation of the output for
certain input values, and there is no attempt to analyze the code, which produces the
output. The internal structure of the program is ignored. For this reason, functional
testing is sometimes referred to as black-box testing (also called behavioral testing)
in which the content of a black box is not known and the function of black box is
understood completely in terms of its inputs and outputs.
Other names for black-box testing (BBT) include specifications testing, behavioral
testing, data-driven testing, functional testing, and input/output driven testing. In
black-box testing, the tester only knows the inputs that can be given to the system
and what output the system should give. In other words, the basis for deciding test
cases in functional testing is the requirements or specifications of the system or
module. This form of testing is also called functional or behavioral testing.
By applying black-box techniques, we derive a set of test cases that satisfy the
following criteria:
• Test cases that reduce by a count that is greater than one.
• Test cases that tell us something about the presence or absence of classes of
errors.
• The test is unbiased because the designer and the tester are independent of
each other.
• The tester does not need knowledge of any specific programming languages.
• The test is done from the point-of-view of the user, not the designer.
• Test cases can be designed as soon as the specifications are complete.
Test Plan
The test plan is a document that contains different test cases designed to test
different test objects and different testing attributes. The plan puts the test of a
logical and sequential order form according to the chosen strategy, top-down or
bottom-up. Usually, the test plan is a test matrix and list of test cases in accordance
with the execution order of each task. Table 5.1 illustrates the matrix of test and test
cases within the test. Test ID, test name, and test cases are designed well before the
development phase and have been designed for those who conduct the tests. A test
plan states:
Tests-Case Design
Each test case needs proper documentation, preferably in a fixed format. There are
many formats; one format is suggested in Table 5.2:
Table 5.2: Test Case Documentation Format (Source: Agarwal et al., 2010)
SUMMARY
UMIT SUMMARY
In this unit aspects related to the implementation/coding phase and testing were
discussed. In coding phase, a structured programming has been explained more.
The primary objective for test case design is to derive a set of tests that have the
highest likelihood for uncovering errors in the software. To accomplish this objective,
two different categories of test case design techniques are used: white-box testing
and black-box testing.
White-box tests focus on the program control structure. Test cases are derived to
ensure that all statements in the program have been executed at least once during
testing and that all logical conditions have been exercised. Black-box tests are
designed to validate functional requirements without regard to the internal workings
of a program. Black-box testing techniques focus on the information domain of the
software, deriving test cases by partitioning the input and output domain of a
program in a manner that provides thorough test coverage.
The difference between the various testing techniques such as unit testing,
integration and system were explained in detail. The need to implement a test plan,
or a life cycle of software testing and how the techniques and tools are integrated
into this was discussed in this chapter.
REVIEW OF CONCEPTS
Software Implementation:
Software implementation is a process of realizing the design specification as a
program unit.
Software Testing
Testing is a set of activities used to test the source code in order to uncover (and
correct) errors before delivery of software to customer.
Test Case
A test case is a set of instructions designed to discover a particular type of error or
defect in the software system by inducing a failure.
5. With the aid of sketches, explain three basic control structures of the
structured programming.
6. Explain the difference of the following
a. Black-box testing and white-box testing
b. Top-down and bottom-up testing approaches
c. Alpha and beta testing
REFERENCES:
Agarwal B. B., Tayal S. P. and Gupta M., (2010), “Software Engineering &
Testing, an Introduction”, Jones and Bartlett Publishers, ISBN: 978-1-
934015-55-1
Pressman R. S., (2001), “Software Engineering, A Practitioner’ S Approach”
Fifth Edition, McGraw-Hill Higher Education, ISBN 0073655783
Liu Z., (2001), “Object-Otiented Software Development Using UML”, The
United Nations University, UNU-IIST International Institute for Software
Technology, Tech Report 229.