Dynamic White-Box Testing What is code coverage? What are the different types of code coverage? How to derive test cases from control flows?

Slides:



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

Marking Schema question1: 40 marks question2: 40 marks question3: 20 marks total: 100 marks.
Chapter 6 Path Testing Software Testing
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Lecture 11 Instructor Paulo Alencar.
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.
ITEC113 Algorithms and Programming Techniques
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
April 1, R McFadyen1 A Traditional Software Development Process Unit test Integration test System test Detailed design Architectural design.
Nov R McFadyen1 A Traditional Software Development Process Unit test Integration test System test Detailed design Architectural design Analysis.
Nov R. McFadyen1 Metrics Fan-in/fan-out Lines of code Cyclomatic complexity* Comment percentage Length of identifiers Depth of conditional.
White Box Testing Techniques Dynamic Testing. White box testing(1) Source code is known and used for test design While executing the test cases, the internal.
March R. McFadyen1 Software Metrics Software metrics help evaluate development and testing efforts needed, understandability, maintainability.
Testing an individual module
1 CSE1301 Computer Programming: Lecture 15 Flowcharts, Testing and Debugging.
Chapter 18 Testing Conventional Applications
Software Testing and QA Theory and Practice (Chapter 4: Control Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Software Systems Verification and Validation Laboratory Assignment 3
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Lecture 9 Instructor Paulo Alencar.
CMSC 345 Fall 2000 Unit Testing. The testing process.
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 20 Slide 1 Defect testing l Testing programs to establish the presence of system defects.
Path Testing + Coverage Chapter 9 Assigned reading from Binder.
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
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
1 Software Testing. 2 Path Testing 3 Structural Testing Also known as glass box, structural, clear box and white box testing. A software testing technique.
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.
White-box Testing.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
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
Overview Structural Testing Introduction – General Concepts
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]
Dynamic Testing.
White Box Testing by : Andika Bayu H.
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
1 CSE1301 Computer Programming: Lecture 16 Flow Diagrams and Debugging.
White-Box Testing Statement coverage Branch coverage Path coverage
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Verification vs. Validation Verification: "Are we building the product right?" The software should conform to its specification.The software should conform.
CS223: Software Engineering Lecture 26: Software Testing.
White Box Testing. Agenda White-box vs Black-box Program Flow Controls White-box Test Methods Exercises Complexity Q&A.
Testing Integral part of the software development process.
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.
Control Flow Testing Handouts
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Chapter 9, Testing.
Software Engineering (CSI 321)
Outline of the Chapter Basic Idea Outline of Control Flow Testing
Structural testing, Path Testing
Types of Testing Visit to more Learning Resources.
White Box Testing.
CHAPTER 4 Test Design Techniques
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software Testing (Lecture 11-a)
Whitebox Testing.
Whitebox Testing.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Unit III – Chapter 3 Path Testing.
Presentation transcript:

Dynamic White-Box Testing What is code coverage? What are the different types of code coverage? How to derive test cases from control flows?

Structure Based Techniques Also known as ‘white-box’ or ‘glass-box’ testing technique because here the testers require knowledge of how the software is implemented Developers use structure-based techniques in component testing and component integration testing Can be used in system and acceptance testing, but the structures are different – Coverage of menu options or major business transactions

Structure Based Techniques Serve two purposes 1.Test coverage measurement – Used first to assess the amount of testing performed by tests derived from specification- based techniques, i.e. to assess coverage 2.Structural test case design – Used to design additional tests with the aim of increasing the test coverage.

Test Coverage The degree (expressed as percentage) to which a specified coverage item has been exercised by a test suite

Benefit of code coverage It helps in finding areas of a program not exercised by a set of test cases It creates additional test cases to increase coverage It helps in determining a quantitative measure of code coverage, which indirectly measure the quality of the application or product.

Disadvantage of code coverage There is danger in using a coverage measure. 100% coverage does not mean 100% tested It measures coverage of what has been written in the code; it cannot say anything about the code that has not been written If a specified function has not been implemented or a function was omitted from the specification, then structure-based techniques cannot find it

Test Coverage Test coverage can be used in any level of the testing – System or acceptance level, the coverage items may be requirements, menu options, screens, or typical business transactions – State transition testing: coverage measures: Percentage of states visited Percentage of (valid) transitions exercised (known as Chow’s 0- switch coverage) Percentage of pairs of valid transitions exercised (‘transition pairs’ or Chow’s 1-switch coverage) Longer series of transitions, such as transition triples, quadruples, etc. Percentage of invalid transitions exercised (from the state table)

Types of Test Coverage At component testing level, we have three types of test coverage – Statement coverage – Decision coverage – Condition coverage

Statement coverage Also known as line coverage In this process each line of code needs to be checked and executed statement coverage: The percentage of executable statements that have been exercised by a test suite

Statement coverage Example To achieve 100% statement coverage, one test case is required(X value is greater than Y) X = 12 and Y = 10. READ X READ Y I F X>Y THEN Z = 0 ENDIF

Statement coverage Example 2 The following test cases were executed, how much statement coverage did the tester achieve? – TEST SET 1 Test 1_1: X= 2, Y = 3 Test 1_2: X =0, Y = 25 Test 1_3: X =47, Y = 1 1 READ X 2 READ Y 3 Z =X + 2*Y 4 IF Z> 50 THEN 5 PRINT large Z 6 ENDIF 83% statement coverage

Statement coverage Advantage of statement coverage: – It checks the flow of different paths in the program and it also ensure that whether those path are tested or not. Disadvantage of statement coverage: – It cannot test the false conditions. – It does not report that whether the loop reaches its termination condition. – It does not understand the logical operators

Decision coverage Also known as branch coverage A decision is an IF statement, a loop control statement, or a CASE statement It covers both the true and false conditions Decision coverage: The percentage of decision outcomes that have been exercised by a test suite

Decision coverage Example 1 TEST SET 2: Test 2_1: A = 20, B = 15 1 READ A 2 READ B 3 C = A – 2 *B 4 IFC <0THEN 5 PRINT “C negative” 6 ENDIF

Decision coverage Example 1 Lets produce control flow diagram TEST SET 2 Test 2_1: A = 20, B = 15 Test 2_2: A = 10, B = 2

Decision coverage 100% decision coverage guarantees 100% statement coverage

Decision coverage Advantages of decision coverage – To validate that all the branches in the code are reached – To ensure that no branches lead to any abnormality of the program’s operation Disadvantages of decision coverage: – This metric ignores branches within boolean expressions

Condition coverage Condition coverage reports the true or false outcome of each conditione 1.PRINT "Hello World" 2.IF Date$ = " " AND Time$ = "00:00:00" THEN 3. PRINT "Happy New Year" 4.END IF 5.PRINT "The date is: "; Date$ 6.PRINT "The time is: "; Time$ 7.END

CONTROL FLOW TESTING The execution of a sequence of instructions from the entry point to the exit point of a program unit is called a program path A specific input value causes a specific program path to be executed; it is expected that the program path performs the desired computation, thereby producing the expected output value.

CONTROL FLOW GRAPH A control flow graph (CFG) is a detailed graphical representation of a program unit. Three symbols are used:

CONTROL FLOW GRAPH Label each computation and decision box with a unique integer Branches of a decision box are labeled with T and F Do not label a merge node

CONTROL FLOW GRAPH FILE *fptr1, *fptr2, *fptr3; /* These are global variables. */ int openfiles(){ /* This function tries to open files "file1", "file2", and "file3" for read access, and returns the number of files successfully opened. The file pointers of the opened files are put in the global variables. */ int i = 0; if( ((( fptr1 = fopen("file1", "r")) != NULL) && (i++) && (0)) || ((( fptr2 = fopen("file2", "r")) != NULL) && (i++) && (0)) || ((( fptr3 = fopen("file3", "r")) != NULL) && (i++)) ); return(i); }

Control Flow Testing Cyclomatic Complexity – A technique using mathematical graph theory to describe the complexity of a software module. – Maximum number of tests that are required to reach branch coverage – C = e – n+2p e=the number of edges in the graph (i.e., the number of arrows) n=the number of nodes (i.e., the chunks of code that are executed without loops and/or branches) p=the number of independent procedures

Path Testing Steps: 1: Draw a control flow graph 2: Calculate Cyclomatic complexity 3: Choose a “basis set” of paths 4: Generate test cases to exercise each path

Example Procedure sort do while records remain read record if record field1 =0 thenprocess record store in buffer else if record field2 =0 thenreset counter else process record end if end do end 1: 2: 3: 4: 5: 6: 7: 8: 9:

1, 9 1, 2,3, 8, 1, 9 1, 2, 4, 5, 7, 8, 1, 9 1, 2, 4, 6, 7, 8, 1, 9 Test cases should be derived so that all of these paths are executed Example Control Flow Graph

Another Example- ReturnAverage

CONTROL FLOW GRAPH ReturnAverage

Example - ReturnAverage

Quiz FindMean (FILE ScoreFile) { float SumOfScores = 0.0; int NumberOfScores = 0; float Mean=0.0; float Score; Read(ScoreFile, Score); while (! EOF(ScoreFile) { if (Score > 0.0 ) { SumOfScores = SumOfScores + Score; NumberOfScores++; } Read(ScoreFile, Score); } /* Compute the mean and print the result */ if (NumberOfScores > 0) { Mean = SumOfScores / NumberOfScores; printf(“ The mean score is %f\n”, Mean); } else printf (“No scores found in file\n”); } Draw Control Graph for this code