Control Flow based Testing

Slides:



Advertisements
Similar presentations
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 5 Looping.
Advertisements

1 CIS Jan Overview Selection Statements –If Statement –Else –Nested If-Else –Switch Repetition Statements –While statement –For Statement.
Iteration This week we will learn how to use iteration in C++ Iteration is the repetition of a statement or block of statements in a program. C++ has three.
Switch structure Switch structure selects one from several alternatives depending on the value of the controlling expression. The controlling expression.
Loops Programming. COMP104 Lecture 9 / Slide 2 Shortcut Assignment l C++ has a set of operators for applying an operation to a variable and then storing.
Computer Science 1620 Lifetime & Scope. Variable Lifetime a variable's lifetime is finite Variable creation: memory is allocated to the variable occurs.
SOFTWARE TESTING WHITE BOX TESTING 1. GLASS BOX/WHITE BOX TESTING 2.
CONTROL FLOW IN C++ Satish Mishra PGT CS KV Trimulgherry.
Chapter 4 Program Control Statements
Lecture 4 Introduction to Programming. if ( grade ==‘A’ ) cout
CPS120: Introduction to Computer Science Decision Making in Programs.
Chapter 4 Selection Structures: Making Decisions.
CPS120: Introduction to Computer Science Decision Making in Programs.
Chapter 5 Loops. Overview u Loop Statement Syntax  Loop Statement Structure: while, for, do-while u Count-Controlled Loops u Nested Loops u Loop Testing.
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
Program Flow Control - Looping Addis Ababa Institute of Technology Yared Semu April 2012.
GAME102 - INTRO WHILE LOOPS G. MacKay. Fundamental Control Structures  STRAIGHT LINE  CONDITIONAL  LOOPS.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 ‏ Control Structures.
CSC1201: Programming Language 2 Lecture 1 Level 2 Course Nouf Aljaffan (C) CSC 1201 Course at KSU1.
Loops cause a section of a program to be repeated a certain number of times. The repetition continues while a condition remains true. When a condition.
Repetition Statements (Loops) The do while Loop The last iteration structure in C++ is the do while loop. A do while loop repeats a statement or.
Copyright © 2012 Pearson Education, Inc. Chapter 5: Loops.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 5 Looping.
REPETITION STATEMENTS - Part1  Also called LOOP STATEMENTS OR LOOP STRUCTURES 1 C++ Statements that repeat one or more actions while some condition is.
Chapter 6 - Repetition. while Loop u Simplest loop u Two parts: test expression and loop body u Pre-tested loop –Execute loop body if test true –Bypass.
Variables  A piece of memory set aside to store data  When declared, the memory is given a name  by using the name, we can access the data that sits.
CPS120: Introduction to Computer Science Decision Making in Programs.
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
Copyright 2006 Addison-Wesley Brief Version of Starting Out with C++ Chapter 5 Looping.
Lecture 7 – Repetition (Loop) FTMK, UTeM – Sem /2014.
White-Box Testing Statement coverage Branch coverage Path coverage
Chapter five exercises. a. false; b. true; c. false; d. true; e. true; f. true; g. true; h. false.
Introduction to Loop. Introduction to Loops: The while Loop Loop: part of program that may execute > 1 time (i.e., it repeats) while loop format: while.
Looping I (while statement). CSCE 1062 Outline  Looping/repetition construct  while statement (section 5.1)
Chapter 4 Repetition Structures
Software TestIng White box testing.
REPETITION CONTROL STRUCTURE
CHAPTER 4 REPETITION CONTROL STRUCTURE / LOOPING
Variables A piece of memory set aside to store data
CS1010 Programming Methodology
Chapter 5: Loops and Files.
CONTROL FLOW TESTING.
Structural testing, Path Testing
White-Box Testing.
Chapter 2.2 Control Structures (Iteration)
Control Statements Kingdom of Saudi Arabia
Control Structures Combine individual statements into a single logical unit with one entry point and one exit point. Used to regulate the flow of execution.
Programming Fundamentals
לולאות קרן כליף.
Flow of Control.
Control Structures Combine individual statements into a single logical unit with one entry point and one exit point. Used to regulate the flow of execution.
Flow of Control.
Random Number Generation
Introduction to Programming
Introduction to Programming
Alternate Version of STARTING OUT WITH C++ 4th Edition
Conditional Construct
Flow of Control.
CPS120: Introduction to Computer Science
White-Box Testing Techniques I
Chapter 4: Control Structures I (Selection)
Control Structures Part 1
Let’s all Repeat Together
Alternate Version of STARTING OUT WITH C++ 4th Edition
By Hector M Lugo-Cordero September 3, 2008
Statements and flow control
Recursion.
Repetition Statements (Loops) - 2
CPS120: Introduction to Computer Science
Programming Fundamental
Presentation transcript:

Control Flow based Testing Šarūnas Juškevičius IFM - 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

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

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).

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;

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;

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'; }

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"); }

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; }

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

Questions ?

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?