Software Testing - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Software Testing

Description:

31-day months for 1,3,5,7,8,10, and 12. 30-day months for 4,6,9, and 11. February which is 28 for leap years and 29 otherwise. Input 13, 7, 6, 2. Year ... – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 16
Provided by: usersC1
Category:
Tags: software | testing

less

Transcript and Presenter's Notes

Title: Software Testing


1
Software Testing
  • Section 6.4 (JIAs)
  • Chapter 13 (ALBINGs)

2
Black-box Testing
  • Midterm Guideline
  • Black box vs. white box?
  • Equivalence Testing
  • Inputs are portioned into equivalence classes
  • Assumes that systems behave similarly for all
    members of an equivalence class ? need only 1
    test member from each class
  • sqrt
  • Consists of two steps
  • Identification of equivalence classes (ec)
  • Coverage Every possible input belongs to one ec
  • Disjointedness No input belongs to more than one
    ec
  • Representation If an failure occurs at one
    input, then error is excepted for all other
    members of the same ec

3
Black-box Testing
  • Selection of test inputs
  • A sample from every ec
  • Example A method that returns number of days in
    a month given the month and year
  • public int getNumDaysInMonth(int Month,int year)

4
Black-box Testing Example
  • Month
  • Valid values 1,2,312 ? values outside 1, 12
    are invalid
  • Discrete
  • ECs
  • Invalid (outside 1, 12)
  • 31-day months for 1,3,5,7,8,10, and 12
  • 30-day months for 4,6,9, and 11
  • February which is 28 for leap years and 29
    otherwise
  • Input 13, 7, 6, 2
  • Year
  • Valid values 0 to MaxInt ? negative years are
    invalid
  • Not Discrete
  • ECs
  • Invalid (negative years)
  • Leap
  • Non-leap
  • Input -2000, 1904, 1901

5
Black-box Testing Example
  • Construct test cases by exhaustively combining
    the two inputs
  • Month 2, year -2000
  • Month 2, year 1901
  • Month 2, year 1904
  • Month 6, year -2000
  • Month 6, year 1901
  • Month 6, year 1904
  • Month 7, year -2000
  • Month 7, year 1901
  • Month 7, year 1904
  • Month 13, year -2000
  • Month 13, year 1901
  • Month 13, year 1904
  • OR Construct test cases by simply combining the
    two inputs
  • Month 2, year -2000
  • Month 6, year 1901
  • Month 7, year 1904
  • Month 13, year 1901

6
Boundary Testing
  • Focuses on conditions at the bounds of the
    equivalence classes
  • i.e. Exceptional cases
  • Assumptions
  • Developers often overlook special cases at the
    boundaries
  • 0, empty strings, year 2000
  • In our example, February represents several
    boundary cases
  • Years that are multiple of 4 are leap
  • But, years multiple of 100 are not unless if they
    are multiple of 400 also
  • E.g. 2000 is leap year but 1900 is not

7
Boundary Testing
  • Additional test cases due to boundary cases
  • Month 2, year 2000
  • Month 2, year 1900
  • Always combine both equivalence and boundary
    testing
  • Start with equivalence testing
  • Instead of picking any sample, pick a bound
  • See if other exceptional cases are required for
    boundary situations
  • Convert numeric grade to a letter grade

8
White-box Testing
  • Focus here is on code coverage
  • Every statement in the component is executed at
    least once
  • Four types of white-box testing
  • Statement Testing
  • Branch Testing
  • Loop Testing
  • Path Testing

9
Path testing
  • Make sure all paths in the program are executed
  • By exercising all possible paths through the
    code, at least once, most faults will trigger
    failures
  • Identifying paths requires knowledge of the
    source code and data structures
  • First we construct flowchart of the component
  • Diamonds are decisions
  • Associations represent flow of control
  • Rectangles are blocks of code

10
(No Transcript)
11
Equivalent flowchart for the getNumDaysInMonth()
method
year lt 1
throw1
month in (1,3,5,7,10,12)
n31
month in (4,6,9,11)
n30
month 2
leap(year)
throw2
n29
n28
return
12
getNumDaysInMonth() method
13
White-box Testing
  • Complete path testing consists of designing test
    cases so that every path is traversed once
  • i.e. select an input for the true branch and
    another for the input for the false branch
  • Test cases
  • Year 0, month 1 throw1
  • Year 1901, month 1 n31 return
  • Year 1901, month 4 n30 return
  • Year 1901, month 2 n29 return
  • Year 1904, month 2 n28 return
  • Year 1901, month 0 throw1

14
Unit-testing Heuristics
  • Create unit tests as soon as object design is
    completed
  • Test before coding
  • Code until tests succeed
  • Execute the test cases
  • Re-execute test cases every time a change is made
  • Create a test harness
  • Automate as much as possible
  • Manual testing involves a tester feeding
    predefined inputs into the system
  • using the user interface, a command line console
    or a debugger
  • costly and error prone
  • Building a test harness is an investment that can
    only be paid off test if there are many times

15
JUnit
  • http//www.junit.org
  • Automates the process of running tests, letting
    programmer quickly see whether the program
    returns the expected results
  • A handful of classes which can be used to build
    and bundle test cases for testing applications
  • Recommendations
  • Design
  • Build stubs (makes testing much easier using
    Eclipse)
  • Test
  • Code until tests succeed!
Write a Comment
User Comments (0)
About PowerShow.com