0% found this document useful (0 votes)
12 views64 pages

Statement and Decision Coverage in Testing

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views64 pages

Statement and Decision Coverage in Testing

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Software QC & Testing

Presented By.
[Link] Mahmoud

Faculty of computers and Artificial Intelligence, Fayoum University, IS&CS department, Fourth Level
2024
Chapter 4- Part2
Statemen
t
Coverage

Achieve
Measure SC
100 % SC
Quiz Time
• Given the following program fragment:

• What is the minimum number of test cases needed


to achieve 100% statement coverage?
If x = 3
A. 1 Print (“hello”)
B. 2
C. 3
D. 4
Quiz Time
• Given the following program fragment:

• What is the minimum number of test cases needed


to achieve 100% statement coverage?
If x = 3
A. 1 Print (“hello”)
B. 2
C. 3
D. 4
Quiz Time
• How many test cases are necessary to achieve 100 % statement coverage

A. 1

B. 4 Print sum (int a, int b) {


C. 3
int result = a + b;
if (result > 0)
D. 2 print (“red”, result)
else if (result < 0)
print (“blue”,
result)
}
Quiz Time
• How many test cases are necessary to achieve 100 % statement coverage

A. 1

B. 4 Print sum (int a, int b) {


C. 3
int result = a + b;
if (result > 0)
D. 2 print (“red”, result)
else if (result < 0)
print (“blue”,
result)
}
Quiz Time
• Given the following program fragment:

• What is the minimum number of test cases needed If day =Monday


to achieve 100% statement coverage? then statement a
Else
statement b
A. 1 End if
B. 2
C. 3
D. 4
Quiz Time
• Given the following program fragment:

• What is the minimum number of test cases needed If day =Monday


to achieve 100% statement coverage? then statement a
Else
statement b
A. 1 End if
B. 2
C. 3
D. 4
How to measure statement coverage ?

𝑵𝒖𝒎𝒃𝒆𝒓 𝒐𝒇 𝒔𝒕𝒂𝒕𝒆𝒎𝒆𝒏𝒕𝒔 𝒄𝒐𝒗𝒆𝒓𝒆𝒅


𝑺𝒕𝒂𝒕𝒆𝒎𝒆𝒏𝒕 𝒄𝒐𝒗𝒆𝒓𝒂𝒈𝒆 =
𝑻𝒐𝒕𝒂𝒍 𝒏𝒖𝒎𝒃𝒆𝒓 𝒐𝒇 𝒔𝒕𝒂𝒕𝒆𝒎𝒆𝒏𝒕𝒔
Quiz Time
• Which one of the following is the BEST description of statement coverage?

a. It is a metric which is used to calculate and measure the percentage of test cases that have
been executed
b. It is a metric, which is used to calculate and measure the percentage of statements in the
source code which have been executed
c. It is a metric, which is used to calculate and measure the number of statements in the
source code which have been executed by test cases that are passed
d. It is a metric that give a true/false confirmation if all statements are covered or not
Quiz Time
• Which one of the following is the BEST description of statement coverage?

a. It is a metric which is used to calculate and measure the percentage of test cases that have
been executed
b. It is a metric, which is used to calculate and measure the percentage of statements in the
source code which have been executed
c. It is a metric, which is used to calculate and measure the number of statements in the
source code which have been executed by test cases that are passed
d. It is a metric that give a true/false confirmation if all statements are covered or not
Quiz Time
• How is statement coverage determined?

a. Number of test decision points divided by the number of test cases


b. Number of decision outcomes tested divided by the total number of executable statements
c. Number of possible test case outcomes divided by the total number of function points
d. Number of executable statements tested divided by the total number of executable
statements
Quiz Time
• How is statement coverage determined?

a. Number of test decision points divided by the number of test cases


b. Number of decision outcomes tested divided by the total number of executable statements
c. Number of possible test case outcomes divided by the total number of function points
d. Number of executable statements tested divided by the total number of executable
statements
Decision

Coverag
e

Achieve
Measure
100 %
DC
DC
If X < Y X<Y
Y = 0;
X=X+
1;
Else Y = 0
X=Y
X=X+1
X=Y;
How many Test cases are required to
achieve 100 % decision coverage ?

End
If X < Y X<Y
Y = 0;
X=X+
1;
Else 1 Y = 0
X=Y
X=X+1
X=Y;
How many Test cases are required to
achieve 100 % decision coverage ?

End
If X < Y X<Y
Y = 0;
X=X+ 2

1;
Else 1 Y = 0
X=Y
X=X+1
X=Y;
How many Test cases are required to
achieve 100 % decision coverage ?

End
X<Y

If X < Y
Y = 0; Y = 0
X=X+ X=X+1
How many1Test
; cases are required to
achieve 100 % decision coverage ?

End
X<Y

If X < Y
Y = 0; 1 Y = 0
X=X+ X=X+1
How many1Test
; cases are required to
achieve 100 % decision coverage ?

End
X<Y

If X < Y
Y = 0; 1 Y = 0 2

X=X+ X=X+1
How many1Test
; cases are required to
achieve 100 % decision coverage ?

End
If X < Y X<Y
Y = 0;
X=X+
1;
Else Y = 0
X=Y
X=X+1
X=Y;
What is the difference between a
decision and a decision outcome ?

End
Decision

If X < Y X<Y
Y = 0;
X=X+ Decision Outcome Decision Outcome

1;
Else Y = 0
X=Y
X=X+1
X=Y;
What is the difference between a
decision and a decision outcome ?

End
How to measure decision coverage ?

𝑵𝒖𝒎𝒃𝒆𝒓 𝒐𝒇 𝑫𝒆𝒄𝒊𝒔𝒊𝒐𝒏 𝑶𝒖𝒕𝒄𝒐𝒎𝒆𝒔 𝑪𝒐𝒗𝒆𝒓𝒆𝒅


𝑫𝒆𝒄𝒊𝒔𝒊𝒐𝒏 𝒄𝒐𝒗𝒆𝒓𝒂𝒈𝒆 =
𝑻𝒐𝒕𝒂𝒍 𝒏𝒖𝒎𝒃𝒆𝒓 𝒐𝒇 𝑫𝒆𝒄𝒊𝒔𝒊𝒐𝒏 𝑶𝒖𝒕𝒄𝒐𝒎𝒆𝒔
Quiz Time
• The following statement refers to decision coverage: “When the code contains only a single
‘if’ statement and no loops or CASE statements, any single test case we run will result in 50%
decision coverage.”
• Which of the following sentences is correct?

A. The sentence is true. Any single test case provides 100% statement coverage and therefore
50% decision coverage
B. The sentence is true. Any single test case would cause the outcome of the “if” statement to
be either true or false
C. The sentence is false. A single test case can only guarantee 25% decision coverage in this
case
D. The sentence is false. The statement is too broad. It may be correct or not, depending on
the tested software
Quiz Time
• The following statement refers to decision coverage: “When the code contains only a single
‘if’ statement and no loops or CASE statements, any single test case we run will result in 50%
decision coverage.”
• Which of the following sentences is correct?

A. The sentence is true. Any single test case provides 100% statement coverage and therefore
50% decision coverage
B. The sentence is true. Any single test case would cause the outcome of the “if” statement to
be either true or false
C. The sentence is false. A single test case can only guarantee 25% decision coverage in this
case
D. The sentence is false. The statement is too broad. It may be correct or not, depending on
the tested software
Quiz Time
• Which TWO of the following statements about the relationship between statement coverage
and decision coverage are true?

A. Decision coverage is stronger than statement coverage.


B. Statement coverage is stronger than decision coverage.
C. 100% statement coverage guarantees 100% decision coverage
D. 100% decision coverage guarantees 100% statement coverage
E. Decision coverage can never reach 100%.
Quiz Time
• Which TWO of the following statements about the relationship between statement coverage
and decision coverage are true?

A. Decision coverage is stronger than statement coverage.


B. Statement coverage is stronger than decision coverage.
C. 100% statement coverage guarantees 100% decision coverage
D. 100% decision coverage guarantees 100% statement coverage
E. Decision coverage can never reach 100%.
Quiz Time
• If you have a section of code that has one simple IF statement, how many tests will be
needed to achieve 100% decision coverage?

A. 1
B. 2
C. 5
D. Unknown with this information
Quiz Time
• If you have a section of code that has one simple IF statement, how many tests will be
needed to achieve 100% decision coverage?

A. 1
B. 2
C. 5
D. Unknown with this information
Experience-based Test Techniques
• When applying experience-based test techniques, the test cases are derived from the
tester’s skill and intuition, and their experience with similar applications and technologies.

• These techniques can be helpful in identifying tests that were not easily identified by other
more systematic techniques.
Experience-based Test Techniques

• Depending on the tester’s approach and experience, these techniques may achieve widely
varying degrees of coverage and effectiveness.

• Coverage can be difficult to assess and may not be measurable with these techniques.
Error Guessing
• Error guessing is a technique used to anticipate the
occurrence of mistakes, defects, and failures, based
on the tester’s knowledge, including:

• How the application has worked in the past

• What types of mistakes the developers tend to


make

• Failures that have occurred in other


applications
Error Guessing
• A methodical approach to the error guessing
technique is to create a list of possible mistakes,
defects, and failures, and design tests that will
expose those failures and the defects that
caused them.

• These mistake, defect, failure lists can be built


based on experience, defect and failure data, or
from common knowledge about why software
fails.
Exploratory Testing
• In exploratory testing, informal tests are designed,
executed, logged, and evaluated dynamically during
test execution.

• The test results are used to learn more about the


component or system, and to create tests for the
areas that may need more testing.

• Exploratory testing is sometimes conducted using


session-based testing to structure the activity.
Exploratory Testing
• In session-based testing, exploratory testing is
conducted within a defined time-box, and the tester
uses a test charter containing test objectives to
guide the testing.

• Exploratory testing is most useful when there are


few or inadequate specifications or significant time
pressure on testing.
Exploratory Testing
• Exploratory testing is also useful to
complement other more formal testing
techniques.

• Exploratory testing is strongly associated with


reactive test strategies.

• Exploratory testing can incorporate the use of other


black-box, white-box, and experience-based
techniques.
Checklist-based Testing
• In checklist-based testing, testers design, implement, and
execute tests to cover test conditions found in a checklist.

• As part of analysis, testers create a new checklist or expand an


existing checklist, but testers may also use an existing checklist
without modification.

• Such checklists can be built based on experience, knowledge


about what is important for the user, or an understanding
of why and how software fails.
Checklist-based Testing
• Checklists can be created to support various test types,
including functional and non-functional testing.

• In the absence of detailed test cases, checklist-based


testing can provide guidelines and a degree of
consistency.

• As these are high-level lists, some variability in the


actual testing is likely to occur, resulting in potentially
greater coverage but less repeatability.
Quiz Time
• Which of the following situations is NOT suited for using exploratory testing?

A. When there is time pressure, and/or the requirements are incomplete or


inapplicable
B. When the system is developed and tested incrementally.
C. When only new and inexperienced testers are available
D. When the main part of the application can be tested only at the customer’s
site.
Quiz Time
• Which of the following situations is NOT suited for using exploratory testing?

A. When there is time pressure, and/or the requirements are incomplete or


inapplicable
B. When the system is developed and tested incrementally.
C. When only new and inexperienced testers are available
D. When the main part of the application can be tested only at the customer’s
site.
Quiz Time
• Which of the following is a good reason to use experience-based testing?

A. You can find defects that might be missed by more formal techniques
B. You can test for defects that only experienced users would encounter
C. You can target the developer’s efforts to the areas that users will be more
likely to use
D. It is supported by strong tools and can be automated
Quiz Time
• Which of the following is a good reason to use experience-based testing?

A. You can find defects that might be missed by more formal techniques
B. You can test for defects that only experienced users would encounter
C. You can target the developer’s efforts to the areas that users will be more
likely to use
D. It is supported by strong tools and can be automated
Quiz Time
• If you are using error guessing to target your testing, which type of testing are
you doing?

A. Specification-based
B. Structure-based
C. Experience-based
D. Reference-based
Quiz Time
• If you are using error guessing to target your testing, which type of testing are
you doing?

A. Specification-based
B. Structure-based
C. Experience-based
D. Reference-based
Quiz Time
• What is error guessing?

A. A testing technique used to guess where a developer is likely to have made a


mistake
B. A technique used for assessing defect metrics
C. A development technique to verify that all error paths have been coded
D. A planning technique used to anticipate likely schedule variances due to
faults
Quiz Time
• What is error guessing?

A. A testing technique used to guess where a developer is likely to have made a


mistake
B. A technique used for assessing defect metrics
C. A development technique to verify that all error paths have been coded
D. A planning technique used to anticipate likely schedule variances due to
faults
Quiz Time
• When exploratory testing is conducted using time-boxing and test charters,
what is it called?

A. Schedule-based testing
B. Session-based testing
C. Risk-based testing
D. Formal chartering
Quiz Time
• When exploratory testing is conducted using time-boxing and test charters,
what is it called?

A. Schedule-based testing
B. Session-based testing
C. Risk-based testing
D. Formal chartering
• A certain degree of independence often makes the tester more effective at finding
defects due to differences between the author’s and the tester’s cognitive biases.

• Independence is not, however, a replacement for familiarity, and developers can


efficiently find many defects in their own code.
Testing’s Degree of Independence (lowest to highest)
1. No independent testers; developers testing their own code

2. Independent developers or testers within the development teams or the project team

3. Independent test team or group within the organization

4. Independent testers from the business organization or


user community, or with specializations in specific
test types

5. Independent testers external to the organization, either


working on-site (insourcing) or off-site (outsourcing)
Benefits & Drawbacks of Independence
Drawbacks of Independence
Benefits of Independence • Isolation from the development team
• Independent testers are likely to recognize different
kinds of failures • Developers may lose a sense of responsibility
for quality

• An independent tester can verify, challenge, or • Independent testers may be seen as a bottleneck or
disprove assumptions made by stakeholders blamed for delays in release

• Independent testers may lack some important


information
Test
Role
s

Test
Teste
Leader
r
Test Manager Tasks
• Test policy-Test Strategy-Test Plan
• Test monitoring & Control (Test progress report-test summary report)
• Initiate the analysis, design, implementation, and execution of tests
• Configuration Management
• Metrics
• Tools selection
• Test Environment Implementation Decision
• Develop the skills and careers of testers
Tester Tasks
• Review and contribute to test plans
• Assess requirements for testability
• Test conditions, test cases, test procedures, test data, & test
execution schedule
• Test Environment setup
• Test Execution
• Test automation
• Non-Functional Testing
• Review tests developed by others

You might also like