Testing Modules

Module versus system testing

Two driving questions in designing module tests

Does the MUT do any I/O?

Does the MUT call functions from other modules?

MUT: Module Under Test

Input module testing: overview

Module service
Input's job is to load the lines in stdin into the LineStorage module.
Calls LSAddLine for each line in stdin
Calls LSAddWord for each word in each line

Test harness
Sample input files are needed.
A driver is needed to invoke INInit and INLoad.
A stub is needed for LSAddLine and LSAddWord.
A csh script is needed to invoke the driver for each input file.

WordTable module testing: overview

Module service
WordTable's job is to determine whether a given word is a noise word.
Does no I/O.
Does not call functions from any other KWIC module.

Test harness
A driver is needed to invoke the WordTable functions and check the return values.

LineStorage module testing: overview

Module service
LineStorage's job is to store the lines, providing access to the ith word in the jth line.
Does no I/O.
Does not call functions from any other KWIC module.

Test harness
A driver is needed to invoke the LineStorage functions and check the return values.

ShiftSort module testing: overview

Module service
ShiftSort's job is to provide access to the ith word in the jth line in a shifted and sorted version of the lines stored in LineStorage.
Does no I/O.
Does call LineStorage functions: LSNumLines, LSNumWords, LSGetWord.
Does call the WordTable function WTIsMember

Test harness
A driver is needed to invoke the ShiftSort functions and check the return values.
A stub is needed to simulate the 3 LineStorage functions.
A stub is needed to simulate WTIsMember.

Output module testing: overview

Module service
Output's job is to format the shifted, sorted lines offered by ShiftSort.
Writes to stdout.
Calls ShiftSort: SSNumLines, SSNumWords, SSGetWord, SSGetShiftNum.

Test harness
A driver is needed to invoke the Output functions.
A stub is needed to simulate ShiftSort.
A csh script is needed to invoke driver and compare act and exp.

Input module testing: details

Test case selection

Example: LineStorage/driver.C

LineStorage module testing: details