Download presentation
Presentation is loading. Please wait.
Published byJulius Johnson Modified over 9 years ago
1
Overview of Software Testing 07/12/2013 WISTPC 2013 Peter Clarke
2
Outline of Presentation Testing Terminology Testing Approaches Levels of Testing Unit Testing 2
3
What is software testing? Software testing is the process of operating software under specified conditions, observing or recording the results and making an evaluation of some aspect of the software. (IEEE/ANSI std 610.12-1990) 3
4
CEN 4010 Class 17 - 7/11 4 Overview of Testing - Terminology Software testing is the dynamic verification of the behavior of a program on a finite set of test cases, suitably selected from the usually infinite execution domain, against the expected behavior. (Guide to the Software Engineering Body of Knowledge 2004 Version)
5
Testing Terminology The following defns are taken from Binder 2000 and McGregor & Sykes 2001. Failure – is the manifested inability of a system or component to perform a required function within specified limits e.g. abnormal termination, or unmet time and space constraints of the software. Fault - incorrect step, process, or data definition in the software. Error - a human action that produces a fault. 5
6
6 Introduction to Testing Theory D R F d..F(d) T t F(t)
7
Testing Concepts Test case components: 1.Name – identifies the test case, it is a good idea to derive the name from the requirement being tested. 2.Purpose – states the purpose of the test and relates it to the requirement (or scenario). 3.Test set up – describe the h/w and s/w and environment required for a successful test. 4.Input – description of the input data or commands. 5.Expected output (or Oracle) – expected test results against which the output of the test is compared. 7
8
Testing Concepts cont Test cases are classified depending on which aspect of the system model is tested: –Blackbox (specification-based or functional) tests focus on the input/output behavior (or functionality) of the component. Tests do not deal with the internal aspects of the component nor with the behavior or the structure of the components. –Whitebox (structural or implementation-based) tests focus on the internal structure of the component. That is, test cases are constructed based on the code that implements the software. 8
9
Testing Concepts cont Combination of blackbox and whitebox testing is referred to as graybox testing. Regression testing includes the re-execution of prior tests after a change, this ensures that the functionality that worked before the change has not been affected. 9
10
Testing Concepts cont Test criteria - The criteria that a system or component must meet in order to pass a given test. [IEEE 610] There are two types of testing criteria: 1.Test data selection criterion – represents a rule used to determine which test cases to select. 2.Test data adequacy criterion – a rule used determine whether or not sufficient testing has been performed. 10
11
Levels of Testing Unit Testing - refers to tests that verify the functionality of a specific section of code, usually at the function level. In an object-oriented environment, this is usually at the class level, and the minimal unit tests include the constructors and destructors. (wikipedia, 2010) Integration Testing - is any type of software testing that seeks to verify the interfaces between components against a software design. Components may be integrated in an iterative way or all together ("big bang"). (wikipedia, 2010) 11
12
Levels of Testing System Testing - testing a completely integrated system to verify that it meets its requirements. (wikipedia, 2010) See http://en.wikipedia.org/wiki/Software_testinghttp://en.wikipedia.org/wiki/Software_testing 12
13
Unit Testing Focuses on the building blocks of the software system i.e., objects and subsystems. Many unit testing techniques have been devised including: equivalence testing, state-based testing, boundary testing, domain testing, control flow-based testing (statement, branch). 13
14
Unit Testing – Equivalence Partitioning Equivalence partitioning is a blackbox testing technique that minimizes the number of test cases. Possible inputs are partitioned into equivalence testing classes, and a test case is selected from each class. Assumption - system behaves in a similar way for all members of an equiv. class. Criteria used to determine equivalence classes: coverage, disjointedness, representation. 14
15
Unit Testing – Equivalence Partitioning Equivalence classValue for month inputValue for year input Months with 31 days, non-leap yrs. 7 (July)1901 Months with 31 days, leap yrs.7 (July)1904 Months with 30 days, non-leap yrs. 6 (June)1901 Months with 30 days, leap yrs.6 (June)1904 Months with 28 or 29 days, non- leap yrs. 2 (February)1901 Months with 28 or 29 days, leap yrs. 2 (February)1904 15 Example: Valid inputs to test the getNumberDaysInMonth() method
16
Unit Testing – Boundary Analysis Test cases are generated using the extremes of the input domain, e.g. maximum, minimum, just inside/outside boundaries, typical values, and error values. It is similar to Equivalence Partitioning but focuses on "corner cases“. Exercise: write test case input using boundary analysis for the getNumberDaysInMonth() method. 16
17
Control Flow Adequacy Criteria Flow Graph (FG) [Binder 00] -A segment is represented by a node in the FG (a sphere). A segment is one or more contiguous statements with no conditionally executed statements. -A conditional transfer of control is a branch. A branch is represented by an outgoing edge in the FG. -The entry point of a method is represented by the entry node, which is a node no incoming edges. The exit point of a method is represented by the exit node, which has no outbound edges. 17
18
18 Control Flow Adequacy Criteria cont Example: Source code public int Fun(int x){ k = 0; while (x <= 10 && k < 3){ if (x%2 != 0) k = k + 1; x = x + 1; } if (x < 0){ x = 10; k = 0; } return k; } K=0 x<=10 && k<3 x%2 != 0 x=x+1 k=k+1 return k B C D E F I Entry Flow graph A X<0 X = 10 K = 0 T F T T F F G H
19
19 Unit Testing – Statement Coverage 1.Statement coverage – A set P of execution paths satisfies the statement coverage criterion iff for all nodes n in the FG, there is at least one path p in P s.t. n is on the path p. Whitebox testing technique. Generate test data to execute every stmt in the program at least once. Exercise: Indentify value(s) of x to execute every stmt in Fun(int x) at least once.
20
20 Unit Testing – Branch Coverage 2.Branch coverage – A set P of execution paths satisfies the branch coverage criterion iff for all edges e in the FG, there is at least one path p in P s.t. p contains edge e. Whitebox testing technique. Generate test data to exercise the true and false outcomes of every decision. Exercise: Indentify value(s) of x to execute every branch in Fun(int x) at least once.
21
21 Homework Source code 1.public int Fun1(int x, int y){ 2. k = 0; 3. while (x <= 10 && k < 10){ 4.if (x%2 != 0){ 5.k = k + y; 6.k = k – 2; 7.} 8.x = x + 1; 9.k = x + k; 10. } 11. if (x < 0){ 12.x = y; 13.k = k + x; 14. } 15. return k; 16.} 1. Draw a flow graph 2.Identify pairs of values for for x and y that gives: (a) 100% statement coverage (b) 100% branch coverage
22
22 Summary Testing terminology – software testing, test case, test driver, stub, fault, failure, error Testing Approaches – blackbox, whitebox, and graybox testing Levels of Testing – unit, integration, system
23
23 Summary cont Unit Testing –Blackbox: equivalence partitioning and boundary analysis. –Whitebox: statement coverage, branch coverage. Practice exercises were given for each testing technique.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.