Download presentation
Presentation is loading. Please wait.
Published byHarriet Sutton Modified over 9 years ago
1
Informatics 43 – May 5, 2015
2
Restatement of goals Want to verify software’s correctness Need to test Need to decide on test cases No set of test cases is sufficient What is a systematic approach to the selection of test cases that will lead to accurate, thorough, repeatable identification of bugs?
3
Approaches to test case selection “White box” – or structural Test cases based on the structure of the code Can be partially automated “Thorough”ness measured against code qualities “Black box” – or specification based Test cases based on specifications Requires “formal” specs to automate “Thorough”ness measured against either the set of functionality, or the set of inputs
4
The Testing Process Model 1.Decide what to test. 2.Select a test case input, with input I 3.Determine the expected output E. 4.Run the system with the test case input I 5.Capture the actual output A. 6.Compare E and A. Different? Inform programmer 7.Loop back to 1 or 2, if time permits.
5
Back to Black box test case selection Based on specifications, not source code. How to select inputs for test cases? Typical values Boundary values Extreme values Special cases Invalid values Environmental factors, such as date, type of user This is all pretty haphazard.
6
The Testing Process Model (with test case suite focus) 1.Decide what to test. 2.Select a suite of test case inputs, with input I1, I2, … 3.For I n, determine the expected output E. 4.Run the system with the test case input I n 5.Capture the actual output A. 6.Compare E and A. Different? Inform programmer 7.Loop back to 1 or 2 or 3, if time permits.
7
Back to Black box test case selection Equivalence Class Partitioning – a systematic approach to selecting a suite of test cases. 1.Identify the set of all possible inputs (to what is being tested). 2.Identify a basis for subdividing the set of inputs. stated requirements size, order, structure your smarts 3.Use this basis to divide the set of all possible inputs into subsets (domain into subdomains). 4.From each subset/subdomain, select a representative to be a test case input.
8
Back to Black box test case selection An example The Multiply function: Input: two numbers Output: a single number which is the multiplicative product of the inputs
9
Equivalence Class Partitioning with Multiply 1.Identify the set of all possible inputs. the set of all ordered pairs of integers numbers 2.Identify a basis for subdividing the set of inputs. The value of the first number in the pair 3.Use this basis for dividing the set of all possible inputs into subsets (domain into subdomains). a. all pairs with 0 as first; b. all pairs with 1 as first, c. all pairs with -1 as first, d.all pairs with 2 as first, etc. 3.From each subset/subdomain, select a representative. a. (0, 4) b. (1, 20) c. (-1, 8) d. (2, 20000000000000)
10
Back to Black box test case selection Another example The QuizAverage function: Input: a list of numbers Output: a single number which is the average of the numbers on the input list, not counting the lowest number on the list.
11
Equivalence Class Partitioning with QuizAverage 1.Identify the set of all possible inputs. all lists of numbers between 0 and 100 inclusive, with 2 decimal places Identify a basis for subdividing the set of inputs. list length grade scale (60s, 70s, 80s, 90s) value of expected output number of lowest scores the mean or median of the inputs 3.Use this basis to divide the set of all possible inputs into subsets (domain into subdomains). a.Lists of length 10-100 b. lists of length 0-10 c. lists of length 100+ A. 0 B. 1 C >1 0-50, 50-85, 85-100 4.From each subset/subdomain, select an element. A. () B. (57.20) C. (40, 70) (5, 6) (60, 60, 60, 60) (89, 90, 91)
12
The Testing Process Model 1.Decide what to test. 2.Select a test case input. 3.Determine the expected output E. 4.Run the system with the test case input. 5.Capture the actual output A. 6.Compare E and A. Different? Inform programmer. 7.Loop back to 1 or 2, if time permits. Equivalence class partitioning
13
The Testing Process Model 1.Decide what to test. 2.Select a test case input. 3.Determine the expected output E. 4.Run the system with the test case input. 5.Capture the actual output A. 6.Compare E and A. Different? Inform programmer. 7.Loop back to 1 or 2, if time permits. Where does this come from?
14
Testing Oracles Where does a test case’s “expected output” come from? A “testing oracle” is a mechanism for deciding whether a test case execution succeeded or failed. Critical to testing. Difficult to create systematically – typically done with guesswork. Can be automated with formal specifications.
15
Testing Oracle Example The cosine function. You test input = 0.5, the actual output is 0.8775825619. What’s your oracle?
16
Oracles from Formal Specifications Formal specification of QuizAverage QuizAverage(list) (sumof(list) – min(list)) / (sizeof(list) – 1) Formal specifications can be interpreted to compute or evaluate results.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.