WHITE BOX TESTING IS4500 Copyright © 2012 by The Cathris Group and Martin J. Schedlbauer. All Rights Reserved. Do Not Duplicate or Distribute Without Written.

Slides:



Advertisements
Similar presentations
Lecture 2: testing Book: Chapter 9 What is testing? Testing is not showing that there are no errors in the program. Testing cannot show that the program.
Advertisements

Chapter 14 Software Testing Techniques - Testing fundamentals - White-box testing - Black-box testing - Object-oriented testing methods (Source: Pressman,
Chapter 14 Testing Tactics
Chapter 6 Path Testing Software Testing
Whitebox Testing Fra: CS Fall Whitebox Testing AKA Structural, Basis Path Test Normally used at unit level Assumes errors at unit level are.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
Creator: ACSession No: 13 Slide No: 1Reviewer: SS CSE300Advanced Software EngineeringFebruary 2006 Testing - Techniques CSE300 Advanced Software Engineering.
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.
IMSE Week 18 White Box or Structural Testing Reading:Sommerville (4th edition) ch 22 orPressman (4th edition) ch 16.
Chapter 18 Testing Conventional Applications
DAIMI(c) Henrik Bærbak Christensen1 White-box Testing Let us open the box...
SOFTWARE TESTING WHITE BOX TESTING 1. GLASS BOX/WHITE BOX TESTING 2.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
System/Software Testing
Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
CMSC 345 Fall 2000 Unit Testing. The testing process.
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
Path Testing + Coverage Chapter 9 Assigned reading from Binder.
Agenda Introduction Overview of White-box testing Basis path testing
Introduction to Software Testing Chapter 8.1 Building Testing Tools –Instrumentation Paul Ammann & Jeff Offutt
White-box Testing.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt.
Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic.
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.
Dynamic Testing.
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
IS4500 – SOFTWARE QUALITY ASSURANCE TESTING STRATEGIES Copyright © 2012 by Martin Schedlbauer, Ph.D. All Rights Reserved. Do Not Duplicate or Distribute.
White-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 7.
Structural Coverage. Measurement of structural coverage of code is a means of assessing the thoroughness of testing. Such metrics do not constitute testing.
Dynamic White-Box Testing What is code coverage? What are the different types of code coverage? How to derive test cases from control flows?
CS223: Software Engineering Lecture 26: Software Testing.
PREPARED BY G.VIJAYA KUMAR ASST.PROFESSOR
Software TestIng White box testing.
White-Box Testing Pfleeger, S. Software Engineering Theory and Practice 2nd Edition. Prentice Hall, Ghezzi, C. et al., Fundamentals of Software Engineering.
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Cyclomatic complexity
Software Engineering (CSI 321)
CompSci 230 Software Construction
Paul Ammann & Jeff Offutt
Data Coverage and Code Coverage
CONTROL FLOW TESTING.
Structural testing, Path Testing
White-Box Testing Techniques
Control Flow based Testing
Types of Testing Visit to more Learning Resources.
White-Box Testing.
White-Box Testing.
White-Box Testing Techniques II
Paul Ammann & Jeff Offutt
CHAPTER 4 Test Design Techniques
UNIT-4 BLACKBOX AND WHITEBOX TESTING
White-Box Testing.
Paul Ammann & Jeff Offutt
Structural Coverage.
Graph Coverage for Source Code
White-Box Testing Techniques I
Control Structure Testing
Structural Coverage.
White-Box Testing Techniques II
White-Box Testing.
Paul Ammann & Jeff Offutt
Whitebox Testing.
CSE 1020:Software Development
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Unit III – Chapter 3 Path Testing.
Presentation transcript:

WHITE BOX TESTING IS4500 Copyright © 2012 by The Cathris Group and Martin J. Schedlbauer. All Rights Reserved. Do Not Duplicate or Distribute Without Written Consent of the Author. ·

Objectives Upon completion of this chapter you will be able to: ◦ Create test cases based on statement and branch coverage ◦ Calculate statement and branch coverage metrics v Solution Validation & Testing

What is White Box Testing? The basis for white box testing is the test object’s source code. It is a code-based testing technique and therefore the source code must be available and it must be possible to manipulate the code by adding test “hooks”. The general idea is to exercise every part of the code of the test object at least once.

White Box Testing Techniques Flow-oriented test cases that represent the program logic are identified and all paths are executed. The expected result is generally what the programmer wrote not necessarily what the requirements stated.

What is Tested? The overall goal of WBT is to achieve coverage of the entire code base: ◦ Statements ◦ Decisions and branches ◦ Conditions ◦ Paths

Statement Testing This analysis focuses on each statement of the test object. Code is first translated into a control flow graph: ◦ Branches ◦ Sequential statements are a single block as statement execution is guaranteed ◦ All statements must be executed

Test Cases Map out the sequence of control and each path becomes a test case. Ensure that all paths are covered.

C0 Test Completion Criterion The completion criteria for tests can be defined by the following metric: 100% coverage is difficult to achieve and may be too expensive. ◦ For example, how would you trigger all exception handling catches? Statement Coverage = (number of executed statements / total number of statements) * 100%

Dead Code Analysis If complete coverage of all statements is required and some statements cannot be triggered, then that means there is code that is unreachable (“dead code”).

Branch Testing & Coverage In this form of testing, the execution of each statement is not considered. Instead focus is directed to the execution of branches (decisions). Testing should ensure that each branch is taken following a decision. For loops testing should ensure execuction of the body as well as fall-through.

C1 Test Completion Criterion Analogous to the statement coverage, the degree of coverage for branch coverage is defined as: Branch Coverage = (number of executed branches / total number of branches) * 100%

Code Analysis Example 1 private static Point2D.Double calcPathLine(Point s, Point e) { double m = 0.0, b = 0.0; m = (double)(e.y - s.y) / (double)(e.x - s.x); if (Double.isInfinite(m)) if (m < 0.0) m = (-1.0) * Double.MAX_VALUE; else m = Double.MAX_VALUE; b = s.y - (m * s.x); if (Double.isInfinite(b)) if (b < 0.0) b = (-1.0) * Double.MAX_VALUE; else b = Double.MAX_VALUE; return new Point2D.Double(m, b); }

Code Analysis Example 2 double calc_price ( double baseprice, double specialprice, double extraprice, int extras, double discount) { double addon_discount; double result; if (extras >= 3) addon_discount = 10; else if (extras >= 5) addon_discount = 15; else addon_discount = 0; if (discount > addon_discount) addon_discount = discount; result = baseprice / * (100 – discount) + special_price + extraprice / * (100 – addon_discount) return (result) }

Control Flow Graph

Test Cases Which edges in the control flow graph were executed? What is the branch coverage? Does running test 02 improve branch coverage? What additional test cases do you need to improve branch coverage? Which cases would you need to achieve 100% coverage? // test case 01 price = calc_price( ,2000.0,1000.0,3,0); test_ok = test_ok && (abs(price ) < 0.01; // test case 02 price = calc_price( ,3450.0,6000.0,6,0); test_ok = test_ok && (abs(price ) < 0.01;

Summary In this module we learned that: ◦ White box testing complements black box testing 16 Solution Validation & Testing v1.01