Unit Testing - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Unit Testing

Description:

Cartoon of the Day. 7. White Box Methods. Coverage. statement. branch. Dataflow. Mutation ... 1: x = y; 2: if (x 10) { 3: x = x - 5 } 4: z = z - x; ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 13
Provided by: marka6
Category:
Tags: cartoon | testing | unit

less

Transcript and Presenter's Notes

Title: Unit Testing


1
Unit Testing
  • SE 452, Software Verification and Validation
  • Mark Ardis, RIT

2
Role of Unit Testing
  • Assure minimum quality of units before
    integration into system
  • Focus attention on relatively small units
  • Marks end of development step

3
Testing versus Debugging
4
Limits of Testing
  • Testing can never demonstrate the absence of
    errors
  • Exhaustive testing is infeasible
  • Testing may be done imperfectly

5
Strategies for Unit Testing
  • Black box
  • use only specification of program
  • test implementation against its specification
  • White box
  • use structure or other properties of a program to
    generate tests

6
Cartoon of the Day
7
White Box Methods
  • Coverage
  • statement
  • branch
  • Dataflow
  • Mutation

8
Coverage Methods
  • Statement
  • execute each statement
  • Branch
  • execute each branch

9
Statement Coverage
  • Execute each statement in the program
  • Considered minimum criterion for most unit
    testing
  • May be difficult to achieve for error cases

10
Example Program
  • 1 if (a lt 0)
  • 2 return 0
  • 3 r 0
  • 4 c a
  • 5 while (c gt 0)
  • 6 r r b
  • 7 c c - 1
  • 8 return r

11
Statement Tests
  • a 3, b 4
  • executes 1, 3, 4, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 8
  • a -3, b 2
  • executes 1, 2

12
Branch Coverage
  • Execute each branch of the program at least once
  • Differs from statement coverage only for "if"
    statements without "else"s and case statements
    without default cases
  • 1 x y
  • 2 if (x gt 10)
  • 3 x x - 5
  • 4 z z - x
Write a Comment
User Comments (0)
About PowerShow.com