Clear testing goals Flashcards
Software Metrics
System or standard of measurement which gives a value to some property
Coverage
A measure of proportion of a structure that a program, test case, test suite exercises.
List test coverage methods based on rigour from low to high.
- Statement coverage
- Decision coverage
- Condition Coverage
- Condition/Decision Coverage.
- Modified Condition/decision coverage.
What can analysis of structural coverage discover?
- Shortcomings in requirements-based test cases
- inadequacies in requirements
- dead code/deactivated code
- unintended functionalities.
Path coverage
Test suite achieves path coverage if it results in every path in the program taken at least once.
Path coverage v. Exhaustive testing
Not the same. Path coverage ensures each control flow path is seen once. not that all paths have seen all possible values.
Statement Coverage
Test suite achieves Statement coverage if it results in each statement in the program being run at least once.
Statement coverage for: int abs(int x) { int ans = x; if x < 0 { ans = -x } return ans; }
test case: abs(-4).
Hits every statement in the code but doesn’t hit every branch in the program.
Branch Coverage
Test suite achieves branch coverage if it results in each branch in the program being run at least once.
Branch coverage for: int abs(int x) { int ans = x; if x < 0 { ans = -x } return ans; }
test case: abs(-4)
test case: abs(4)
All branches taken in the program.
Path coverage v. Branch coverage?
Path coverage ensures each control flow path is taken.
Branch coverage ensures that each INDIVIDUAL branch is taken.
But there are combinations of branches that may not have been seen!
Condition Coverage
Test suite achieves path coverage if it results in each condition in each branching instruction being both true and false. (true, true) and (false, false) for if (a || b)
Combinatorial coverage
Test suite achieves combinatorial coverage if it results in each condition in each branching instruction being tried in all combinations of truth values.
What is required for combinatorial coverage:
if (avrageMark >= 50 or hardFailCount == 0 or elephantCount > 3) {
…
(50, 0, 4) = (true,true,true)
(50, 0, 3) = (true,true,false)
(50, 1, 4) = (true, false, true)
…
Modified Condition/Decision Coverage
100% branch coverage
100% condition coverage
each entry/exit point is exercised
each condition affects the behaviour independently.
if (a or b)
(TF), (FT), (FF)