2nd Unit ST Notes
2nd Unit ST Notes
The below figure show each level of testing on specific entity. Unit testing is done to test the
source code of the software. Integration testing is done to test the design of the software. System
testing is done to test the SRS document. And finally, Acceptance testing is done to test the
client/user requirement. To check whether the software satisfies the user needs, the software has
to install in the actual environment and tested.
System
SRS
Testing
Integration Design
Testing
Unit Code
Testing
main function. How do you test it without push and pop functions? Instead of the statement that
calls the push function, you can just write a statement that prints “call push here”.
Similarly, you can write a print statement that prints “call pop here” in the place of the statement
that calls pop function. If the main program works, then you can develop the push function,
replace the above print statement with the call to push function, and then test the main program
along with the push function. Then you can develop the pop function and test the program for
entire stack implementation.
NOTE: It may not be possible to test a component/unit in isolation. You may need to write
additional code (stubs, drivers, simulators) to do the testing.
2.1.2 Module Testing
A module is an independent entity in the software. The tested units are integrated into a module
and each module is tested separately for the specifications.
For Example: if the software is a database management system, the modules can be database
(back-end) and the user interface (front-end). The database can be tested separately using the
SQL commands to check correct data retrieval. However, validation of the front-end (forms)
requires a database. So, after testing the back-end module, the front-end can be tested, after
integration.
After completion of testing a module, a module-level test report has to be prepared.
2.1.3 Integration Testing
After the modules are tested, the modules can be integrated together. It is a difficult task to
integrate all the modules together and start testing, as it would be very difficult to do the
debugging. The integration has to be done incrementally and testing is performed step by step.
Once all the modules are integrated together, the system is ready for testing.
Consider an e-learning portal. Some important modules in this portal are given in Figure 2.2.
Broadly, the portal consists of three modules: admin module, tutor module and student module.
E-Learning Portal
• Contractual fulfillment testing: If there are any special contractual obligations, such as
environmental testing for the hardware, testing the system for air-borne applications
(such as in aircraft), then testing is done to fulfill these obligations.
• Regulatory acceptance testing (or conformance testing): The software may be
required to conform to international standards or meet some government requirements. In
such a case, the necessary testing is done. This testing may be done at third party
laboratories or government laboratories.
The various stages of testing are shown in Figure 2.3. For each stage of testing, a test plan has to
be prepared and after the testing is done, a test report has to be prepared. Figure 2.4 describes
pictorially the complete testing process as discussed in this section along with various test plans
to be written at each level.
Unit
Unit
Testing
Testing
Module Module
Testing Testing
Sub-System
Testing Sub-System
Testing
System
Testing
Acceptance
Testing
Figure 2.3 Stages of testing
Client
Design SRS Requirement
Structural Testing:
A structure of a program differs at different levels. At the component level, the structure is the
code. At integration level, the structure is the tree diagram that shows the interconnecting
modules. At system level, the structure is the menu structure, or web page structure or a business
process depending on the application.
NOTE: Structural testing is also called clear-box testing, glass box testing and white box testing.
Structural testing at component level is used to test the implementation of the program. Here,
the source code is looked into for testing the software. Structural testing involves.
a) statement coverage
b) condition coverage
c) path coverage
d) function coverage
a)Statement Coverage
It is advisable that every line in the code is executed at least once. Statement coverage ensures
that each and every statement is executed, that shows all the statements in the program are tested.
Checking it manually is difficult, but tools are available for this. Profilers used to carry out this
statement coverage testing. Profilers indicate the number of times each line in the code is
executed. When you execute a test case, the profiler indicates which lines of code have been
executed and which lines have not been executed.
b)Condition Coverage
It is advisable that every condition in the code is executed at least once. Condition coverage
ensures that each and every condition is executed, that shows all the conditions in the program
are tested.
In branch coverage, inputs are given in such a way that, each branch is executed at least once.
For example:
if (a > 6 && b < 5)
then <statements;
else <statements> ;
Here it has to be certainly ensured that both the 'then' statements and 'else' statements are
executed at least once. The test cases are chosen in such a way that the condition becomes true
and also false. In addition, it is necessary to ensure that each individual condition in the
conditional statement is made true and false, i.e. a > 6 is true and false; b <5 is true and false.
Condition coverage in percentage = (no. of conditions executed / total conditions) * 100
c)Path Coverage
It is advisable that every path in the code is executed at least once. Path coverage ensures that
each and every condition is executed, that shows all the paths in the program are tested.
You can convert a given program into a flow chart and you will know pictorially how many
paths are there. You need to design test cases to ensure that each path is tested at least once.
As an example, consider the flow chart shown in Figure 2.5(a) and the corresponding flow path
given in Figure 2.5 (b). Here, there are two paths to be tested. Hence, test cases need to be
formulated to ensure that both the paths are tested.
Find d
D>0 ?
Calculate Calculate
Real Roots IMG Roots
STOP
Note that path coverage deals with the logical paths in the program. For small programs, the path
coverage can be easily ensured by designing the necessary test cases, however in practical
systems with millions of lines of code, 100% path coverage is not that easy.
Path coverage in percentage = (no. of paths executed / total paths) * 100
4)Function Coverage
It is advisable that every function in the code is executed at least once. Function coverage
ensures that each and every function is executed, that shows all the functions in the program are
tested.
Developing test cases for function coverage is rather easy as compared to developing test cases
for path coverage and condition coverage
Structural Testing at Integration Level
At integration level, the structure is the tree diagram that shows the interconnecting modules.
Consider the various modules of an e-learning portal given in Figure below figure. In this
software, when we carry out the testing at module level, we can consider the various sub-
modules in that module and then work out the testing strategy.
In the student module, the chat, e-mail and on-line content sub-modules can be tested
independently. However, to test the on-line tests sub-module, we need to also consider the on-
line tests allocation sub-module of the tutor module. So, at the testing level, we can consider the
structure of the modules for finalizing the testing strategy.
E-Learning Portal
Compilable Block
Since we are not worried about the internet structure of the program, we are only carrying out a
functional testing. Test cases have to be designed to ensure that the each and every functionality
given in the user requirements is tested.
2.3.3 White Box Testing
In white box testing, the structure of the program is taken into consideration. Using this approach
the logic behind the code can be checked. The objective is to ensure that each and every line of
the code is tested. Consider the example:
If the test case i = 3 and j = 7 is given as input, only the true condition is satisfied and the
corresponding statements are executed. A test case that makes the condition false also needs to
be given, such as i = 6 and j = 3.
…………………………………………………
………………………………………………….
if(a>5 && b<b)
{
k=10
Test Input else Test Output
k=0;
}
Figure 2.9 White-box testing
Run time profilers are used to indicate that which statement is executed and how many times.
For developing highly reliable software, white box testing is a must.
2.3.4 Interface Testing
Interface testing is done to test whether the interface between two subsystems is OK. Interface
testing may be done by the development engineers while carrying out integration. When two
modules have to be integrated, they can be integrated only when the interfaces are correctly
defined. In addition to this type of interface testing by developers, test engineers also may need
to test the interfaces. These interfaces can be:
Hardware-hardware interfaces: These are used to integrate two hardware devices. For
example, suppose you have to interconnect two computers, you have to specify the following
parameters: (a) physical connection (b) electrical parameters and (c) protocol for communication.
If you are testing software, you have to ensure that all the interface specifications are correctly
given and then test whether the necessary communication can be established between the two
hardware devices.
B.L.D.E.A’S SSM POLYTECHNIC, CSE (S.R. INAMDAR) Page 11
Software Testing
Software-software interfaces. These interfaces are used in every application for module
integration. For example Java SDK gives you APIs so that you can develop your own
applications. APIs are the most widely used mechanism for providing software interfaces. If you
are testing an interface that has to be given to the customer, you need to write the test routines for
ensuring that the interface is as per the mechanism specified by the customer.
Hardware software interfaces: In PC/mainframe computers, generally the interface between
the application and the hardware is through the operating system and hence hardware-software
interface is not difficult. But Testing and debugging hardware-software interfaces is more
difficult in embedded systems because the hardware and software are tightly coupled in
embedded systems.
Human-Computer Interface (HCI): This testing differs from application to application. In
PC/mainframe/client-server/web applications, HCI testing is simply testing the GUI. But then,
testing the GUI is not easy-you need to test each and every aspect of the GUI and check the
functionality. In addition, you need to test non-functional aspects such as usability or ease-of-
use, esthetics, etc.. For example, the number of clicks required to carry out a particular action can
be one parameter. If the GUI requires too many clicks and if the screens are deeply nested, then
the GUI is not easy to use.
2.3.5 Use Case Testing
In use-case testing, various use-cases are worked out. The exact sequence of operations done by
a user is worked out and testing is done in the same sequence, to check whether the desired
results are obtained. For example, consider a database application. The GUI for entering the
employee details in a database is shown in Figure 2.10.
Testing is done in by following the use case procedure, i.e. enter the details of a new employees,
add an employee details and then take a print-out and check whether the correct data is printed or
not. If the employee makes a mistake, he will click on the modify button, which modifies the
data and the report is checked again. Use cases can be worked out for adding employee details,
modifying an existing record and deleting a record.
Figure 2.10
B.L.D.E.A’S SSM POLYTECHNIC, CSE (S.R. INAMDAR) Page 12
Software Testing
Imagine that the software developed by the team is given to a Gorilla for testing. The Gorilla will
randomly press some keys, which may be irrelevant to the software and, it may sometimes press
the keys that are acceptable inputs.
This type of testing would bring out the defects when wrong input is given. Ideally, the software
should not misbehave when wrong inputs are given. If the software fails, then the user will lose
the confidence. Gorilla testing is used to check whether defensive programming has been done or
not--through defensive programming, software is made to tolerate wrong inputs.
As it is very difficult to recruit a Gorilla for carrying out this type of testing, you can ask your
project manager to act as one! The testing process is simple, just keep pressing some keys
randomly and check whether the software fails. If a wrong input is given, necessary error
messages have to be displayed. If the system hangs, it is a major defect; if the error messages are
not displayed, the error handling routines need to be improved.
Gorilla testing is highly beneficial for testing games software. When a child gets lost while
playing a game, it randomly presses lots of keys. If the software hangs, then it is really bad
software.
2.3.7 Alpha Testing
When the software reached a mature stage of development, the ends users can test the software
in the presence of the development team so that the users can be guided how to use the software
and the developers can rectify any major problems encountered during the usage of the software.
This type of testing is called alpha testing.
It is always advisable to carry out alpha testing for every project because this will help in getting
an early feedback from the user. Alpha testing is carried out by the users in the presence of the
development team.
During the development time, you would have tested the software in the lab by simulating a
satellite network. However, before making the software available for the users on the satellite
network, you would like to conduct a field trial by installing the software on the satellite network
and testing it through a group of selected users. Once you find out that the software is working
fine, it can be then released for operational use.
A log sheet that gives all the problems encountered during the field trial has to be maintained
with the following details:
• Date
• Preconditions (status of the software before the problem)
• Description of the problem encountered
• Post-condition (status of the software after the problem)
• Impact (whether the software has become unusable or system has to be rebooted,
etc.)
Based on this field trial report, all the defects have to be removed and then the software can be
released.
2.3.10 Performance Testing/Load Testing
Performance testing focuses on the performance parameters, such as the response time
throughput etc. This type of testing is compulsory for client/server applications and web
applications because these applications are accessed simultaneously by a large number of users.
For example, in database systems the response time is a time to obtain a report after clicking on a
specific button. It may be difficult to specify the response times for each and every report to be
generated, so it can be specified as 30 seconds is a reasonable period, but not two minutes.
Figure 2.13 Load testing of client / server application using automated tools
Suppose you need to test a database application or a web application when 100 users
simultaneously accesses the application. For doing the performance testing, you need 100
computers and 100 test engineers! This is not practical; Therefore Performance testing tools has
to be used to do the testing. On a single computer, these tools simulate multiple users (say, 50
users), Hence, with just two computers, you can do the performance testing, as shown in figure
2.13. The simulated users are called virtual users in the performance tool jargon.