Multiple choice technology testing

The following example is a If (condition1 && (condition2 || function1())) statement1; else statement2;

  1. Decision coverage

  2. Condition coverage

  3. Statement coverage

  4. Path Coverage

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The compound condition condition1 && (condition2 || function1()) contains multiple atomic conditions that can be independently true or false. Condition coverage requires testing each atomic condition for both true and false values, which is necessary here since we have condition1, condition2, and the return value of function1(). Decision coverage would only test the overall if/else decision (true/false), statement coverage would only ensure each statement is reached, and path coverage would test all possible paths through the code which is more comprehensive than needed.

AI explanation

To answer this question, we need to understand the different types of coverage criteria used in software testing.

A. Decision coverage - This coverage criteria ensures that each decision point (such as an if statement) in the code is evaluated to both true and false at least once. In this example, the if statement has one decision point, but the conditions inside the if statement are not evaluated separately. Therefore, decision coverage is not satisfied.

B. Condition coverage - This coverage criteria ensures that each condition in a decision point is evaluated to both true and false at least once. In this example, there are two conditions: condition1 and (condition2 || function1()). Condition coverage is satisfied because both conditions are evaluated separately.

C. Statement coverage - This coverage criteria ensures that each statement in the code is executed at least once. In this example, there are two statements: statement1 and statement2. Statement coverage is satisfied because both statements are executed.

D. Path coverage - This coverage criteria ensures that every possible path through the code is executed at least once. In this example, there are multiple paths, depending on the evaluation of the conditions. Path coverage is not satisfied.

Therefore, the correct answer is B) Condition coverage. This coverage criteria ensures that each condition in a decision point is evaluated to both true and false at least once, which is satisfied in this example.