White Box Testing. Agenda White-box vs Black-box Program Flow Controls White-box Test Methods Exercises Complexity Q&A.

Slides:



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

Software Testing Technique. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves.
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.
-- Finishing Design Unit -- Intro to Glass Box Testing ECEN5543 / CSCI 5548 SW Eng of Standalone Programs University of Colorado, Boulder.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
David Woo (dxw07u).  What is “White Box Testing”  Data Processing and Calculation Correctness Tests  Correctness Tests:  Path Coverage  Line Coverage.
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.
BASIS PATH TESTING ● By Tom McCabe ● McCabe, T., "A Software Complexity Measure," IEEE Trans. Software Engineering, vol. SE-2, December 1976, pp
Testing an individual module
DAIMI(c) Henrik Bærbak Christensen1 White-box Testing Let us open the box...
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.
CompSci 230 Software Design and Construction
Cyclomatic Complexity Dan Fleck Fall 2009 Dan Fleck Fall 2009.
White Box Testing.  Path yang berbeda dalam modul software akan dibentuk oleh pilihan kondisional statement seperti IF-THEN-ELSE atau DO WHILE atau DO.
Software Systems Verification and Validation Laboratory Assignment 3
System/Software Testing
CMSC 345 Fall 2000 Unit Testing. The testing process.
White-Box Testing Eshcar Hillel Michael Beder. White Box Testing 2 Tutorial Outline What is White Box Testing? Flow Graph and Coverage Types Symbolic.
CS /51 Illinois Institute of Technology CS487 Software Engineering Software Testing Techniques Mr. David A. Lash.
Agenda Introduction Overview of White-box testing Basis path testing
Software Testing. 2 CMSC 345, Version 4/12 Topics The testing process  unit testing  integration and system testing  acceptance testing Test case planning.
Testing Testing Techniques to Design Tests. Testing:Example Problem: Find a mode and its frequency given an ordered list (array) of with one or more integer.
INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.
White-box Testing.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
White Box Testing Arun Lakhotia University of Southwestern Louisiana P.O. Box Lafayette, LA 70504, USA
Software Construction Lecture 19 Software Testing-2.
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.
Cyclomatic Complexity Philippe CHARMAN Last update:
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?
Software Dynamic White-box Testing Part 2: Data-flow Testing Lecture 7 Prof. Mostafa Abdel Aziem Mostafa.
Software Dynamic White-box Testing Lecture 6 Part 1: Control-flow Testing.
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.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Testing Integral part of the software development process.
Software TestIng White box testing.
TQS - Teste e Qualidade de Software (Software Testing and Quality) Test Case Design: White Box Testing João Pascoal Faria.
BASIS PATH TESTING.
TQS - Teste e Qualidade de Software (Software Testing and Quality) Test Case Design: White Box Testing João Pascoal Faria.
Cyclomatic Complexity
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)
CONTROL FLOW TESTING.
Structural testing, Path Testing
WHITEBOX TESTING APPROACH
Types of Testing Visit to more Learning Resources.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Cyclomatic Complexity
Software Testing (Lecture 11-a)
Cyclomatic Complexity
Structural Coverage.
Cyclomatic Complexity
Structural Coverage.
Whitebox Testing.
Whitebox Testing.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Unit III – Chapter 3 Path Testing.
Presentation transcript:

White Box Testing

Agenda White-box vs Black-box Program Flow Controls White-box Test Methods Exercises Complexity Q&A

What is White-box Testing? Looking at the internal structure of a program and deriving test cases based on the logic or control flow. Test cases can be designed to reach every branch in the code and to exercise each condition Typically done during unit testing Also known as: –Structural Testing –Glass-Box Testing

What is Black-box Testing? Looking at the program from an external point of view and deriving test cases based on the specification. The only criteria upon which the program is judged is if it produces the correct output for a given input.

Why Do Both? Black-box Impossible to write a test case for every possible set of inputs and outputs Some of the code may not be reachable without extraordinary measures Specifications are not always complete White-box Does not address the question of whether or not the program matches the specification Does not tell you if all of the functionality has been implemented Does not discover missing program logic

Basic Program Flow Controls IF IF-Then-Else FOR While Do-While Case

IF Diagram

IF-THEN-ELSE Diagram

FOR or WHILE Diagram

DO-WHILE Diagram

CASE Diagram

Example Code Fragment

Example Control Flow Graph Source: The Art of Software Testing – Glenford Myers

Exercise #1 int main (int argc, char *argv[]) { /* Process CTRL-C Interrupts */ signal(SIGINT,catcher); if (validate_command_line(argc)) return(1); if (job_initialize(argv)) return(1); processTestList(); /* Process all testCases in TestList */ displayResults(); fprintf(stdout,"Test Complete\n"); job_termination(); return(0); } /* main */ Can you diagram this code?

Did You Get Something Like This?

Exercise #2 /* Attempt Statusreadback -log SRB data to logFile */ int process_srb(void) { int srb_count = 0; do { srb_count = read_printer(srb_in); } while (!srb_count); fprintf(logFile,"%s\n",srb_in); return(srb_count); } /* process_srb */ /* Write String to Printer via Parallel or Serial port */ void write_printer (char *outputline) { if (strstr(printertype,"PAR") != NULL) { bwrite_parST(printerport,outputline); } else if (strstr(printertype,"SER") != NULL) { bwwrite_serial(printerport,outputline,strlen(outputline)); } else if (strstr(printertype, "FILE") !=NULL) { fprintf(printerFile,"%s",outputline); } } /* write_printer */ Can you diagram this code?

Did You Get Something Like This?

White-box Test Methods Statement Coverage Decision/Branch Coverage Condition Coverage Decision/Condition Coverage Path Coverage

Example Code Fragment If ((A>1) & (B=0)) then Do; X=X/A; END; If ((A==2) | (X>1)) then Do; X=X+1; END; Source: The Art of Software Testing – Glenford Myers

Statement Coverage Exercise all statements at least once How many test cases?  A=2 and B=0 (ace) Source: The Art of Software Testing – Glenford Myers

Decision/Branch Coverage Each decision has a true and a false outcome at least once How many test cases?  A=2 and B=0 (ace)  A=1 and X=1 (abd) Source: The Art of Software Testing – Glenford Myers

Condition Coverage Each condition in a decision takes on all possible outcomes at least once Conditions: A>1, B=0, A=2, X>1 How many test cases?  A=2, B=0, and X=4 (ace)  A=1, B=1, and X=1 (abd) Source: The Art of Software Testing – Glenford Myers

Decision/Condition Coverage Each condition in a decision takes on all possible outcomes at least once, and each decision takes on all possible outcomes at least once How many test cases?  A=2, B=0, and X=4 (ace)  A=1, B=1, and X=1 (abd) What about these?  A=1, B=0, and X=3  A=2, B=1, and X=1 (abe)

Multiple Condition Coverage Exercise all possible combinations of condition outcomes in each decision Conditions: Source: The Art of Software Testing – Glenford Myers A>1, B=0 A>1, B<>0 A<=1, B=0 A 0 A=2, X>1 A=2, X<=1 A<>2, X>1 A<>2, X<=1

Multiple Condition Coverage How many test cases?  A=2, B=0, X=4  A=2, B=1, X=1  A=1, B=0, X=2  A=1, B=1, X=1 Source: The Art of Software Testing – Glenford Myers (ace) (abe) (abd)

Path Coverage Every unique path through the program is executed at least once How many test cases?  A=2, B=0, X=4 (ace)  A=2, B=1, X=1 (abe)  A=3, B=0, X=1 (acd)  A=1, B=1, X=1 (abd) Source: The Art of Software Testing – Glenford Myers

McCabe’s Cyclomatic Complexity Software metric Developed by Tom McCabe (circa 1976) Directly measures the number of linearly independent paths through a program’s source code, taking into account the various decision points Independent of implementation language Source: Wikipedia

Calculating Complexity

How Complex Should Code Be? <10: Simple module, not much risk 10-20: More Complex; moderate risk 20-50: Complex; high risk >50: Untestable; extremely high risk Source: Carnegie Mellon Software Engineering Institute

Complexity Caveats As code is broken into smaller modules to decrease cyclomatic complexity, structural complexity increases Some modules may have high complexity but are very easy to comprehend and easy to test High complexity numbers are only an indicator of something to investigate