Skip to main content

Description of the method

Instruction testing is the simplest of white-box testing techniques. However, it requires a precise definition of what constitutes an instruction. Instruction is an element of code written in a specific programming language that represents the smallest indivisible unit of execution or is treated as such.

Formulating it in terms of execution excludes all kinds of comments and blank lines from this concept, as they are not subject to execution. All source codes will be represented in such a way that one line of code corresponds to one indivisible instruction. For example, the line of code:

if (x > 0) then y := y + 1

does not constitute an indivisible instruction because increasing y by one will not always occur upon entering the if instruction, but only if the condition of the instruction is satisfied. Therefore, this piece of code should be presented as follows:

if (x > 0) then
    y := y + 1

Now each of the two lines of code constitutes a separate instruction.

The criterion for instruction coverage requires that each instruction be executed at least once during the execution of test cases. In control flow graph terminology, this means that we require each node of the graph to be visited at least once. The basic hypothesis is that if an error occurs in a particular line of the program, then each such line should be executed at least once.

Task 2

The Textbook, section 9.1.1, from the frame [statement testing] up to the listing 9.1 and the paragraph following this listing.

Task 3

Table 9.11. Summary of the Instruction Testing Method

Test ConditionsProgram Instructions or CFG Nodes (Basic Blocks)
Coverage ElementsProgram instructions or CFG nodes (basic blocks)
Coverage CriterionFor each program instruction (basic block), there exists a test whose execution causes that instruction (block) to be executed
Coverage 

or

p=(number of CFG nodes covered/total number of CFG nodes) × 100%