Sunteți pe pagina 1din 4

Experiment 14 (Integration Testing)

Objectives: To identify the usage of stubs or drivers in the context of integration testing scenario.

Estimated Time: 30 minutes

1. Background

Integration testing is carried out after the completion of unit testing and before the software is delivered for
system testing. In top down integration testing, dummy stubs are required for bottom level modules.
Similarly in bottom up testing, dummy drivers are required for top level modules.

1.1 Top down Testing: In this approach testing is conducted from main module to sub module. if the sub
module is not developed a temporary program called STUB is used for simulate the submodule.

1.1.1 Advantages:
 Advantageous if major flaws occur toward the top of the program.
 Once the I/O functions are added, representation of test cases is easier.
 Early skeletal Program allows demonstrations and boosts morale.

1. 1. 2Disadvantages:
 Stub modules must be produced
 Stub Modules are often more complicated than they first appear to be.
 Before the I/O functions are added, representation of test cases in stubs can be difficult.
 Test conditions ma be impossible, or very difficult, to create.
 Observation of test output is more difficult.
 Allows one to think that design and testing can be overlapped.
 Induces one to defer completion of the testing of certain modules.

1.2 Bottom up testing: In this approach testing is conducted from sub module to main module, if the main
module is not developed a temporary program called DRIVERS is used to simulate the main module.

1.2.1 Advantages:

 Advantageous if major flaws occur toward the bottom of the program.


 Test conditions are easier to create.
 Observation of test results is easier.

1.2.2 Disadvantages:

 Driver Modules must be produced.


 The program as an entity does not exist until the last module is added.

2. Stubs and Drivers. These are used in integration testing for Top-Down and Bottom-Up approach.

2.1 A ‘Driver’ is a piece of software that drives (invokes) the Unit being tested. A driver creates necessary
‘Inputs’ required for the Unit and then invokes the Unit. Driver passes test cases to another piece of code.
Test Harness or a test driver is supporting code and data used to provide an environment for testing part of
a system in isolation. It can be called as a software module which is used to invoke a module under test and
provide test inputs, control and, monitor execution, and report test results or most simplistically a line of
code that calls a method and passes that method a value. Figure 1 shows how driver works in testing
different program modules.
Figure 1. Driver implementation

2.1.1 Example Program to Simulate Drivers

public void functionThatCallsPrice(parameters..) // this is the driver


{
int p = price(param1);
System.out.println(“Price: ” + p);
}

public void price(int parameters)


{
//Complex equations and DB integrations that determine the real price.
}

2.2 A ‘Stub’ is a piece of software that works similar to a unit which is referenced by the Unit being
tested, but it is much simpler that the actual unit. A Stub works as a ‘Stand-in’ for the subordinate unit and
provides the minimum required behavior for that unit. A Stub is a dummy procedure, module or unit that
stands in for an unfinished portion of a system. Figure 2 shows how stub works in testing different program
modules.

2.2.1 Four basic types of Stubs for Top-Down Testing are:

 Display a trace message


 Display parameter value(s)
 Return a value from a table
 Return table value selected by parameter

Figure 2. Stubs implementation


2.2.2 Example Program to Simulate Stubs

Public void functionWeTest(parameters…)


{
………..//some codes here
int p = price(param1);
………..//some codes here
}

public void price(int param) //this is the stub


{
return 10; //Provide any value for price to test the other function.
}

3. Problem Description

Consider the scenario of development of software for Travel, Management System (TMS) is in
progress. The TMS software has 3 major modules namely Ticket_Booking_Module,
Hotel_Booking_Module and Taxi_Booking_Module. The Ticket_Booking_Module has 3 sub modules
namely Enquiry_Module, Booking_Module and Update_Module. The enquiry module uses
Date_Validation_Unit, Ticket_Validation_Unit and Place_Validation_Unit. Figure 3 shows the system
module hierarchy.

Travel Management System

Ticket_Booking_Module Hotel_Booking_Module Taxi_Booking_Module

Enquiry_Module Booking_Module Update_Module

View_Module Edit_Module Cancel_Module

Place_Validation_Unit Ticket_Validation_Unit
Date_Validation_Unit

Source_Validation_Unit Destination_Validation_Unit

Figure 3. System module hierarchy


4. Lab Task
Estimated Time: 45 minutes
In the context of the given scenario, identify the usage of stub or driver for the following
situations.
1. Except the Ticket_validation_Unit, the coding and unit testing of all other modules, sub
modules and units of TMS are completed. The top-down integration is in progress for the
TMS software. To carry out the integration testing, which among the following is
necessary? And explain why you have choose these Stubs/Drivers
a) A Stub for Ticket_Validation_Unit
b) A Driver For Ticket_Validation_Unit
c) A Stub for Enquiry_Module
d) A Driver for Enquiry_Module
e) A Stub For Ticket_Booking_Module
f) A Driver For Ticket_Booking_Module

Note: Write the letter of your choice and explanation in the given table below, add more rows if necessary.

Letter of your choice Explanation

2. The coding and unit testing of all the module, sub modules and units of TMS are
completed except the Update_Module (coding and testing for Edit_Module,
Cancel_Module and View_Module are also completed). The bottom-up integration is to
be started for the TMS software. Mention any stub or driver needed to carry out the
integration testing? Type your answer in the given table below, add more rows if
necessary.

Stubs Drivers

3. Except the Taxi_Booking_Module, the coding and unit testing of all other modules, sub
modules and units of TMS are completed. The top-down integration is to be started for
the TMS software. Mention any stub or driver needed to carry out the integration testing?
Type your answer in the given table below, add more rows if necessary.

Stubs Drivers

S-ar putea să vă placă și