Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Name: Auzan Ahmed

SAP ID : 70109028

Section : 8-D

Subject : Software Testing & Implementation

ASSIGNMENT #3.

Exercise 1: How many tests are required to achieve 100% statement coverage?

To achieve 100% statement coverage for the given code, we need to execute all statements at
least once. In this case, we have the following statements:

1. If Age \( <17 \)

2. Display error message

3. Else

4. Display 'customer OK'

5. End if

2 Tests are required to achieve 100% statement coverage,

The statement coverage requires each statement to be executed at least once. Looking at the
flowchart provided:

If A is greater than or equal to 17, the program will display 'customer OK.'

If A is less than 17, an error message will be displayed.


To achieve 100% statement coverage, we need to test both branches of the conditional statement.
Therefore, we need to test for both A<17 and 17

There are three possible scenarios:

1. Age < 17: In this case, statements 1 and 2 will be executed, and statements 3, 4, and 5 will not
be executed.

2. Age >= 17: In this case, statements 1 and 3 will be executed, and statements 2, 4, and 5 will
not be executed.

3. Age >= 17: In this case, statements 1, 3, 4, and 5 will be executed, and statement 2 will not be

executed.

To achieve 100% statement coverage, we need at least two test cases:

1. Test case 1: Age < 17 (to cover statements 1 and 2)

2. Test case 2: Age >= 17 (to cover statements 3, 4, and 5)

Therefore, the minimum number of tests required to achieve 100% statement coverage for the
given code is two.

A≥17. This requires a minimum of 2 tests.

Exercise 2: How many tests are required to achieve 100% statement coverage?

8 Tests are required to achieve 100% statement coverage


C. The core claim of the question is to determine the number of tests required to achieve 100%
statement coverage based on the given diagram.

Rationale:

To achieve 100% statement coverage, each statement in the code must be executed at least once
during testing.

The diagram provided shows the different statements and their connections.

Based on the diagram:

1. Start at 1, go to 2, then 3, then 8.

2. To cover all statements, you need to test for both "y" and "n" conditions at each decision point.

3. Therefore, you need to test for "y" and "n" at points 2 and 3, which leads to a total of 4 tests (2
tests at point 2 and 2 tests at point 3).

You might also like