Presentation is loading. Please wait.

Presentation is loading. Please wait.

Control Flow based Testing

Similar presentations


Presentation on theme: "Control Flow based Testing"— Presentation transcript:

1 Control Flow based Testing
Šarūnas Juškevičius IFM - 2/2

2 Control flow based Test Types
Statement coverage Execute every statement at least once The simplest , weakest type of testing Branch coverage Exercise all control statements in the program Subsumes statement coverage All combinations of control transfers may not be checked Path coverage Execute all paths from program’s entry to exit Subsumes branch coverage Number of paths is exponential to the number of branches Many paths are impossible to exercise

3 Fundamental Path Selection Criteria:
Ensure every instruction in the routine has been exercised at least once Every decision (branch or case statement) has been taken in each possible direction at least once A sufficient number of paths to achieve coverage Selection of short, functionally sensible paths Minimizing the number of changes from path to path - preferably only one decision changing at a time Favour more but simpler paths over fewer, complicated paths

4 control flow statements Categories:
continuation at a different statement (unconditional branch or jump), executing a set of statements only if some condition is met (choice - i.e., conditional branch), executing a set of statements zero or more times, until some condition is met (i.e., loop - the same as conditional branch), executing a set of distant statements, after which the flow of control usually returns (subroutines, co-routines, and continuations), stopping the program, preventing any further execution (unconditional halt).

5 unconditional branch or jump
#include <iostream.h> main() { int i, j, n; cout << "n? "; cin >> n; for (i = 1; i <= n; i++) if (i > 10) goto finished; for (j = n; j >= i; j--) cout << "* "; } cout << endl; } finished: cout << "Finished!" << endl; return 0;

6 conditional branch #include <iostream.h> using namespace std; int main(void) { int num1, num2; cout << „Enter two numbers::"; cin >> num1; cin >> num2; if (num1 > num2) cout << "First number is bigger than second" << endl; } else cout << "Second number is bigger than first" << endl; return 0;

7 Loops #include <iostream.h> void main() { int n; cout << "Enter a number > 0::"; cin >> n; while(n>0) cout <<"Decremented value is::"<< n <<'\n'; n--; }; cout << "Enter a valid number" <<'\n'; }

8 subroutines, coroutines, and COntinuations
#include <stdio.h> int main() { int i = 0; do i++; printf_s("before the continue\n"); continue; printf("after the continue, should never print\n"); } while (i < 3); printf_s("after the do loop\n"); }

9 unconditional halt #include <cstdlib> #include <iostream> using namespace std; int main() { cout << 1; exit(0); // terminate and return 0 to operating system // The following statements never execute cout << 2; return 0; }

10 Bubble Sort 1) False 2) True, false 3) True, true, true 4) True, true, false

11 Questions ?

12 Questions What are the types of control flow based testing?
Can it be used as a standalone testing method? What problems you might encounter using this method? Is it white-box or a black-box testing method? Some of fundamental path selection criterions?


Download ppt "Control Flow based Testing"

Similar presentations


Ads by Google