SlideShare ist ein Scribd-Unternehmen logo
1 von 32
White Box Testing 
Len Schroath 
September 18, 2007
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 Completen"); 
• 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,"%sn",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; 
• 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) 
(abe)
Multiple Condition Coverage 
• Exercise all possible 
combinations of 
condition outcomes in 
each decision 
• Conditions: 
A>1, B=0 
A>1, B<>0 
A<=1, B=0 
A<=1, B<>0 
A=2, X>1 
A=2, X<=1 
A<>2, X>1 
A<>2, X<=1 
Source: The Art of Software Testing – Glenford Myers
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) 
(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
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
Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

Seminar on Software Testing
Seminar on Software TestingSeminar on Software Testing
Seminar on Software TestingBeat Fluri
 
Session 8 assertion_based_verification_and_interfaces
Session 8 assertion_based_verification_and_interfacesSession 8 assertion_based_verification_and_interfaces
Session 8 assertion_based_verification_and_interfacesNirav Desai
 
Se (techniques for black box testing ppt)
Se (techniques for black box testing ppt)Se (techniques for black box testing ppt)
Se (techniques for black box testing ppt)Mani Kanth
 
Software Engineering (Testing techniques)
Software Engineering (Testing techniques)Software Engineering (Testing techniques)
Software Engineering (Testing techniques)ShudipPal
 
Testing and types of Testing
Testing and types of TestingTesting and types of Testing
Testing and types of TestingMunaam Munawar
 
Static white box testing lecture 12
Static white box testing lecture 12Static white box testing lecture 12
Static white box testing lecture 12Abdul Basit
 
Equivalence partitions analysis
Equivalence partitions analysisEquivalence partitions analysis
Equivalence partitions analysisVadym Muliavka
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and typesConfiz
 
Unit 3 Control Flow Testing
Unit 3   Control Flow TestingUnit 3   Control Flow Testing
Unit 3 Control Flow Testingravikhimani
 

Was ist angesagt? (20)

Unit testing
Unit testing Unit testing
Unit testing
 
Seminar on Software Testing
Seminar on Software TestingSeminar on Software Testing
Seminar on Software Testing
 
Types of testing
Types of testingTypes of testing
Types of testing
 
Session 8 assertion_based_verification_and_interfaces
Session 8 assertion_based_verification_and_interfacesSession 8 assertion_based_verification_and_interfaces
Session 8 assertion_based_verification_and_interfaces
 
Black box & white-box testing technique
Black box & white-box testing techniqueBlack box & white-box testing technique
Black box & white-box testing technique
 
White box testing
White box testingWhite box testing
White box testing
 
Software Verification & Validation
Software Verification & ValidationSoftware Verification & Validation
Software Verification & Validation
 
3.software testing
3.software testing3.software testing
3.software testing
 
Se (techniques for black box testing ppt)
Se (techniques for black box testing ppt)Se (techniques for black box testing ppt)
Se (techniques for black box testing ppt)
 
Introduction to Software Test Automation
Introduction to Software Test AutomationIntroduction to Software Test Automation
Introduction to Software Test Automation
 
Black Box Testing
Black Box TestingBlack Box Testing
Black Box Testing
 
White box ppt
White box pptWhite box ppt
White box ppt
 
Software Engineering (Testing techniques)
Software Engineering (Testing techniques)Software Engineering (Testing techniques)
Software Engineering (Testing techniques)
 
Pumping lemma
Pumping lemmaPumping lemma
Pumping lemma
 
Testing and types of Testing
Testing and types of TestingTesting and types of Testing
Testing and types of Testing
 
Static white box testing lecture 12
Static white box testing lecture 12Static white box testing lecture 12
Static white box testing lecture 12
 
Equivalence partitions analysis
Equivalence partitions analysisEquivalence partitions analysis
Equivalence partitions analysis
 
Chapter 5 - Test Management
Chapter 5 - Test ManagementChapter 5 - Test Management
Chapter 5 - Test Management
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and types
 
Unit 3 Control Flow Testing
Unit 3   Control Flow TestingUnit 3   Control Flow Testing
Unit 3 Control Flow Testing
 

Andere mochten auch

White Box Testing
White Box TestingWhite Box Testing
White Box TestingMade Aditya
 
12 white box testing-fixed
12 white box testing-fixed12 white box testing-fixed
12 white box testing-fixedJasmine Tulin
 
Designing Teams for Emerging Challenges
Designing Teams for Emerging ChallengesDesigning Teams for Emerging Challenges
Designing Teams for Emerging ChallengesAaron Irizarry
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with DataSeth Familian
 

Andere mochten auch (7)

White Box Testing
White Box TestingWhite Box Testing
White Box Testing
 
12 white box testing-fixed
12 white box testing-fixed12 white box testing-fixed
12 white box testing-fixed
 
White Box Testing V0.2
White Box Testing V0.2White Box Testing V0.2
White Box Testing V0.2
 
Lesson 2....PPT 1
Lesson 2....PPT 1Lesson 2....PPT 1
Lesson 2....PPT 1
 
White Box Testing
White Box TestingWhite Box Testing
White Box Testing
 
Designing Teams for Emerging Challenges
Designing Teams for Emerging ChallengesDesigning Teams for Emerging Challenges
Designing Teams for Emerging Challenges
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with Data
 

Ähnlich wie White box testing-200709

white-box-testing.pptx
white-box-testing.pptxwhite-box-testing.pptx
white-box-testing.pptxSurajMolla3
 
Class9_SW_Testing_Strategies.pdf
Class9_SW_Testing_Strategies.pdfClass9_SW_Testing_Strategies.pdf
Class9_SW_Testing_Strategies.pdfFarjanaParvin5
 
DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)Steve Upton
 
1_Introduction.pptx
1_Introduction.pptx1_Introduction.pptx
1_Introduction.pptxASVKVinayak
 
Code Analysis-run time error prediction
Code Analysis-run time error predictionCode Analysis-run time error prediction
Code Analysis-run time error predictionNIKHIL NAWATHE
 
Unit 2 Unit level testing.ppt
Unit 2 Unit level testing.pptUnit 2 Unit level testing.ppt
Unit 2 Unit level testing.pptPerfectMe2
 
Software Engineering (Testing techniques)
Software Engineering (Testing techniques)Software Engineering (Testing techniques)
Software Engineering (Testing techniques)ShudipPal
 
Introduzione allo Unit Testing
Introduzione allo Unit TestingIntroduzione allo Unit Testing
Introduzione allo Unit TestingStefano Ottaviani
 
Dynamic Testing
Dynamic TestingDynamic Testing
Dynamic TestingJimi Patel
 
New software testing-techniques
New software testing-techniquesNew software testing-techniques
New software testing-techniquesFincy V.J
 
Software Testing- Principles of testing- Mazenet Solution
Software Testing- Principles of testing- Mazenet SolutionSoftware Testing- Principles of testing- Mazenet Solution
Software Testing- Principles of testing- Mazenet SolutionMazenetsolution
 
Software testdesign
Software testdesignSoftware testdesign
Software testdesign柏宇 陳
 
Software testing: an introduction - 2017
Software testing: an introduction - 2017Software testing: an introduction - 2017
Software testing: an introduction - 2017XavierDevroey
 
Формальная верификация как средство тестирования (в Java)
Формальная верификация как средство тестирования (в Java)Формальная верификация как средство тестирования (в Java)
Формальная верификация как средство тестирования (в Java)SQALab
 
Shift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David LaulusaShift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David LaulusaQA or the Highway
 
2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easierChristian Hujer
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxSyed Zaid Irshad
 

Ähnlich wie White box testing-200709 (20)

11 whiteboxtesting
11 whiteboxtesting11 whiteboxtesting
11 whiteboxtesting
 
white-box-testing.pptx
white-box-testing.pptxwhite-box-testing.pptx
white-box-testing.pptx
 
Class9_SW_Testing_Strategies.pdf
Class9_SW_Testing_Strategies.pdfClass9_SW_Testing_Strategies.pdf
Class9_SW_Testing_Strategies.pdf
 
DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)
 
1_Introduction.pptx
1_Introduction.pptx1_Introduction.pptx
1_Introduction.pptx
 
Code Analysis-run time error prediction
Code Analysis-run time error predictionCode Analysis-run time error prediction
Code Analysis-run time error prediction
 
Unit 2 Unit level testing.ppt
Unit 2 Unit level testing.pptUnit 2 Unit level testing.ppt
Unit 2 Unit level testing.ppt
 
Klee and angr
Klee and angrKlee and angr
Klee and angr
 
Software Engineering (Testing techniques)
Software Engineering (Testing techniques)Software Engineering (Testing techniques)
Software Engineering (Testing techniques)
 
Introduzione allo Unit Testing
Introduzione allo Unit TestingIntroduzione allo Unit Testing
Introduzione allo Unit Testing
 
Unit 4 testing
Unit 4 testingUnit 4 testing
Unit 4 testing
 
Dynamic Testing
Dynamic TestingDynamic Testing
Dynamic Testing
 
New software testing-techniques
New software testing-techniquesNew software testing-techniques
New software testing-techniques
 
Software Testing- Principles of testing- Mazenet Solution
Software Testing- Principles of testing- Mazenet SolutionSoftware Testing- Principles of testing- Mazenet Solution
Software Testing- Principles of testing- Mazenet Solution
 
Software testdesign
Software testdesignSoftware testdesign
Software testdesign
 
Software testing: an introduction - 2017
Software testing: an introduction - 2017Software testing: an introduction - 2017
Software testing: an introduction - 2017
 
Формальная верификация как средство тестирования (в Java)
Формальная верификация как средство тестирования (в Java)Формальная верификация как средство тестирования (в Java)
Формальная верификация как средство тестирования (в Java)
 
Shift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David LaulusaShift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David Laulusa
 
2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 

Kürzlich hochgeladen

Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptJasonTagapanGulla
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm Systemirfanmechengr
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgsaravananr517913
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdfCaalaaAbdulkerim
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfRajuKanojiya4
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 

Kürzlich hochgeladen (20)

Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.ppt
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm System
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdf
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 

White box testing-200709

  • 1. White Box Testing Len Schroath September 18, 2007
  • 2. Agenda • White-box vs Black-box • Program Flow Controls • White-box Test Methods • Exercises • Complexity • Q&A
  • 3. 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
  • 4. 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.
  • 5. 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
  • 6. Basic Program Flow Controls • IF • IF-Then-Else • FOR • While • Do-While • Case
  • 9. FOR or WHILE Diagram
  • 13. Example Control Flow Graph Source: The Art of Software Testing – Glenford Myers
  • 14. 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 Completen"); • job_termination(); • return(0); • } /* main */ Can you diagram this code?
  • 15. Did You Get Something Like This?
  • 16. 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,"%sn",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?
  • 17. Did You Get Something Like This?
  • 18. White-box Test Methods • Statement Coverage • Decision/Branch Coverage • Condition Coverage • Decision/Condition Coverage • Path Coverage
  • 19. 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; • END; Source: The Art of Software Testing – Glenford Myers
  • 20. 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
  • 21. 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
  • 22. 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
  • 23. 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) (abe)
  • 24. Multiple Condition Coverage • Exercise all possible combinations of condition outcomes in each decision • Conditions: A>1, B=0 A>1, B<>0 A<=1, B=0 A<=1, B<>0 A=2, X>1 A=2, X<=1 A<>2, X>1 A<>2, X<=1 Source: The Art of Software Testing – Glenford Myers
  • 25. 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) (abe) (abd)
  • 26. 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
  • 27. 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
  • 30. 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
  • 31. 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