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

  1. Decision coverage

  2. Condition coverage

  3. Statement coverage

  4. Path Coverage


Correct Option: B

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.

Find more quizzes: