Software Construction Lecture 19 Software Testing-2.

Slides:



Advertisements
Similar presentations
Chapter 14 Software Testing Techniques - Testing fundamentals - White-box testing - Black-box testing - Object-oriented testing methods (Source: Pressman,
Advertisements

CompSci 230 Software Design and Construction Software Quality 2014S2 Black box testing.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
David Woo (dxw07u).  What is “White Box Testing”  Data Processing and Calculation Correctness Tests  Correctness Tests:  Path Coverage  Line Coverage.
Nov R McFadyen1 A Traditional Software Development Process Unit test Integration test System test Detailed design Architectural design Analysis.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
IMSE Week 18 White Box or Structural Testing Reading:Sommerville (4th edition) ch 22 orPressman (4th edition) ch 16.
Testing an individual module
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Chapter 18 Testing Conventional Applications
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
Unit Testing CS 414 – Software Engineering I Don Bagert Rose-Hulman Institute of Technology January 16, 2003.
SOFTWARE TESTING WHITE BOX TESTING 1. GLASS BOX/WHITE BOX TESTING 2.
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
CompSci 230 Software Design and Construction
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Software Systems Verification and Validation Laboratory Assignment 3
System/Software Testing
CMSC 345 Fall 2000 Unit Testing. The testing process.
Testing phases. Test data Inputs which have been devised to test the system Test cases Inputs to test the system and the predicted outputs from these.
Prof. Mohamed Batouche Software Testing.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 20 Slide 1 Defect testing l Testing programs to establish the presence of system defects.
CSC 480 Software Engineering Lecture 14 Oct 16, 2002.
1 Software testing. 2 Testing Objectives Testing is a process of executing a program with the intent of finding an error. A good test case is in that.
Software Testing The process of operating a system or component under specified conditions, observing and recording the results, and making an evaluation.
Agenda Introduction Overview of White-box testing Basis path testing
CSE403 Software Engineering Autumn 2001 More Testing Gary Kimura Lecture #10 October 22, 2001.
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.
Software Construction Lecture 18 Software Testing.
White-box Testing.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
These slides are designed to accompany Software Engineering: A Practitioner’s Approach, 6/e (McGraw-Hill 2005). Slides copyright 2005 by Roger Pressman.1.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
BASIS PATH TESTING.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
White Box Testing Arun Lakhotia University of Southwestern Louisiana P.O. Box Lafayette, LA 70504, USA
Theory and Practice of Software Testing
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
Agent program is the one part(class)of Othello program. How many test cases do you have to test? Reversi [Othello]
White Box Testing by : Andika Bayu H.
CSC 395 – Software Engineering Lecture 27: White-Box Testing.
SOFTWARE TESTING SOFTWARE TESTING Presented By, C.Jackulin Sugirtha-10mx15 R.Jeyaramar-10mx17K.Kanagalakshmi-10mx20J.A.Linda-10mx25P.B.Vahedha-10mx53.
Dynamic White-Box Testing What is code coverage? What are the different types of code coverage? How to derive test cases from control flows?
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
ANOOP GANGWAR 5 TH SEM SOFTWARE TESTING MASTER OF COMPUTER APPLICATION-V Sem.
Defect testing Testing programs to establish the presence of system defects.
CHAPTER 9 - PART 2 Software Testing Strategies. Lesson Outlines ■ White box testing – Data processing and calculation correctness tests – Correctness.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
White Box Testing. Agenda White-box vs Black-box Program Flow Controls White-box Test Methods Exercises Complexity Q&A.
Week 5-6 MondayTuesdayWednesdayThursdayFriday Testing I No reading Group meetings MidtermNo Section Testing II Progress report due Readings out Testing.
Software TestIng White box testing.
BASIS PATH TESTING.
Software Testing.
White-Box Testing Pfleeger, S. Software Engineering Theory and Practice 2nd Edition. Prentice Hall, Ghezzi, C. et al., Fundamentals of Software Engineering.
Software Testing.
Software Engineering (CSI 321)
CompSci 230 Software Construction
Structural testing, Path Testing
Types of Testing Visit to more Learning Resources.
White Box Testing.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software Testing (Lecture 11-a)
Chapter 14 Software Testing Techniques
Chapter 14 Software Testing Techniques
Software Testing “If you can’t test it, you can’t design it”
Whitebox Testing.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
By: Lecturer Raoof Talal
Presentation transcript:

Software Construction Lecture 19 Software Testing-2

Learning Goals for Today D32  Develop a test suite for some code after looking at it. (White- box testing.)  What are your initial questions? (Have you written some already?)  Should I analyse the specification carefully, as in black-box testing, to discover “what the code should be doing”?  Does white-box testing have an advantage, over black-box testing, in testing “what the program is not intended to do”?  Should I carefully test interfaces, exceptions, or error returns, or should I concentrate on confirming the correctness of functional “internal” behaviour?  Start to develop your own “principled approach” to software testing.

White-Box Testing D33  “This strategy derives test data from an examination of the program’s logic  “(and often, unfortunately, at the neglect of the specification).”  What is the overall strategy or “gold standard” for white-box testing?  “Causing every statement in the program to execute at least once”?  No… this is “highly inadequate”.

A Gold Standard for White-Box Testing D34  Exhaustive Path Testing: a gold standard for White-Box Testing  “if you execute, via test cases, all possible paths of control flow through the program, then possibly the program has been completely tested.”  Testing all possible paths of control flow is not enough to prove correctness in a white-box test, so how can this be a gold standard?  Testing all possible inputs is not enough to prove correctness in a black- box text, yet this is still the gold standard for black-box testing.  The justification is the other way around! If you don’t exercise all control paths, then a test case for this path may reveal an obvious bug in this path. Someone might ask: why didn’t you test that path? How would you respond.  Testing all paths is often infeasible.  The gold-standard for black-box testing (of testing all possible inputs) is almost always infeasible.  Even if you know you can’t possibly “reach the gold”, you can still use this standard to measure your progress!

What is a “Possible Path of Control Flow”? D35  The concept of a “unique logic path”, where a “logic path” is the sequence of instructions executed when a program is given a particular input.  If the program has a conditional branch, then it has multiple logic paths (assuming that an input can be found which causes the program to branch, and another input which causes the program not to branch).  Your goal, as a white-box tester, is to devise an input which will “force” the program to take each important path.  We define “path” informally in this course, with reference to a flowchart as on the following slide.

White-Box Testing: An Example D36  Devise a test set for this code. (Inputs: a, b; Outputs: a, x, y.)

White-Box Testing: An Example D37  a = 1, b = 1 ? Yes, this is “red” input… output: a = 1, x = 2, y = 1.

White-Box Testing: An Example D38  a = 1, b = 2 ? Hmmm… x = 3, y = 2; then a = 2, x = 4.

White-Box Testing: An Example D39  a = 1, b = 3 ? Hmmm… x = 4, y = 3; a = 2, x = 7; a = 3, x = 10.

10 Flow Graph Example R1 R2 R3 R4 FLOW CHARTFLOW GRAPH 0

11 Cyclomatic Complexity  Provides a quantitative measure of the logical complexity of a program  Defines the number of independent paths in the basis set  Provides an upper bound for the number of tests that must be conducted to ensure all statements have been executed at least once  Can be computed three ways  The number of regions  V(G) = E – N + 2, where E is the number of edges and N is the number of nodes in graph G  V(G) = P + 1, where P is the number of predicate nodes in the flow graph G  Results in the following equations for the example flow graph  Number of regions = 4  V(G) = 14 edges – 12 nodes + 2 = 4  V(G) = 3 predicate nodes + 1 = 4

12 A Second Flow Graph Example 1 int functionY(void) 2 { 3 int x = 0; 4 int y = 19; 5 A: x++; 6 if (x > 999) 7 goto D; 8 if (x % 11 == 0) 9 goto B; 10 else goto A; 11 B: if (x % y == 0) 12 goto C; 13 else goto A; 14 C: printf("%d\n", x); 15 goto A; 16 D: printf("End of list\n"); 17 return 0; 18 }

13 A Sample Function to Diagram and Analyze 1 int functionZ(int y) 2 { 3 int x = 0; 4 while (x <= (y * y)) 5 { 6 if ((x % 11 == 0) && 7 (x % y == 0)) 8 { 9 printf(“%d”, x); 10 x++; 11 } // End if 12 else if ((x % 7 == 0) || 13 (x % y == 1)) 14 { 15 printf(“%d”, y); 16 x = x + 2; 17 } // End else 18 printf(“\n”); 19 } // End while 20 printf("End of list\n"); 21 return 0; 22 } // End functionZ

14 A Sample Function to Diagram and Analyze 1 int functionZ(int y) 2 { 3 int x = 0; 4 while (x <= (y * y)) 5 { 6 if ((x % 11 == 0) && 7 (x % y == 0)) 8 { 9 printf(“%d”, x); 10 x++; 11 } // End if 12 else if ((x % 7 == 0) || 13 (x % y == 1)) 14 { 15 printf(“%d”, y); 16 x = x + 2; 17 } // End else 18 printf(“\n”); 19 } // End while 20 printf("End of list\n"); 21 return 0; 22 } // End functionZ

When should we stop? D315  Don’t add a test unless it has a reasonable chance of exposing a new bug.  A loop that “works correctly” on two iterations is not very likely to show an obvious problem on the third iteration, so we might stop after testing the green path.  A problem: we don’t know what this program is supposed to do, so how can we choose a “correct” set of output values for each of our test cases in this example??!  This example is an extreme form of white-box testing, in which there is no specification, aside from the code we’re looking at.  In Regression Testing, we gain confidence that the current version of a system has the same behaviour as prior versions.  Regression testing is very useful when you’re porting a program to a new system.  Does “it work the same way” on both systems?  Regression testing is also useful when confirming that recent changes to a program haven’t re-introduced a bug.  (Hmmm… should I add a new test case every time I identify a new bug?)

When should we stop? D316  Don’t add a test unless it has a reasonable chance of exposing a new bug.  A loop that “works correctly” on two iterations is not very likely to show an obvious problem on the third iteration, so we might stop after testing the green path.  A problem: we don’t know what this program is supposed to do, so how can we choose a “correct” set of output values for each of our test cases in this example??!  This example is an extreme form of white-box testing, in which there is no specification, aside from the code we’re looking at.  In Regression Testing, we gain confidence that the current version of a system has the same behaviour as prior versions.  Regression testing is very useful when you’re porting a program to a new system.  Does “it work the same way” on both systems?  Regression testing is also useful when confirming that recent changes to a program haven’t re-introduced a bug.  (Hmmm… should I add a new test case every time I identify a new bug?)

If you test a path… D317  Can you conclude that there are no bugs on a path you have tested? Of course not! … but let’s list some reasons why we may miss some bugs, then think about whether we can write test cases to cover these…  The output we specify for our test case may be incorrect  because we were doing a regression test against a buggy version of our program,  because we interpreted the specification carelessly,  or because the specification wasn’t clear.  What can we do to decrease the number of incorrect test cases we write?  There may be data-sensitive calculations in the path, and we’re only testing a single point of what may be a very non-linear function.  If the path contains “x = a+b” but it should contain “x = a*b”, our case won’t reveal the error if our test input has a=0 or b=0.  Should we write more test cases for paths with data-sensitive computations?  The computation on this path may be non-deterministic.  If a program is multi-threaded, then the value computed on one path may depend greatly on what path another thread is following, and on how far along that path the other thread has already moved. (Do you understand multi-threading?)