260 likes | 532 Views
Overview of Software Testing. WISTPC 2013. Peter Clarke. 07/12/2013. Outline of Presentation. Testing Terminology Testing Approaches Levels of Testing Unit Testing. What is software testing?.
E N D
Overview of Software Testing WISTPC 2013 Peter Clarke 07/12/2013
Outline of Presentation • Testing Terminology • Testing Approaches • Levels of Testing • Unit Testing
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)
CEN 4010 Class 17 - 7/11 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)
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.
Introduction to Testing Theory .F(d) d. F(t) t T F R D
Testing Concepts Test case components: • Name – identifies the test case, it is a good idea to derive the name from the requirement being tested. • Purpose – states the purpose of the test and relates it to the requirement (or scenario). • Test set up – describe the h/w and s/w and environment required for a successful test. • Input – description of the input data or commands. • Expected output(or Oracle) – expected test results against which the output of the test is compared.
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.
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.
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: • Test data selection criterion – represents a rule used to determine which test cases to select. • Test data adequacy criterion – a rule used determine whether or not sufficient testing has been performed.
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)
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_testing
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).
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.
Example: Valid inputs to test the getNumberDaysInMonth() method Unit Testing – Equivalence Partitioning
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.
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.
Control Flow Adequacy Criteria cont Flow graph Entry A 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; } B K=0 F x<=10 && k<3 C G T F X<0 F x%2 != 0 D T T X = 10 K = 0 k=k+1 E H x=x+1 F return k I
Unit Testing – Statement Coverage • Statement coverage – A set P of execution paths satisfies the statement coverage criterioniff for all nodes n in the FG, there is at least one path p in Ps.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.
Unit Testing – Branch Coverage • Branch coverage – A set P of execution paths satisfies the branch coverage criterioniff for all edges e in the FG, there is at least one path p in Ps.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.
Homework Draw a flow graph Identify pairs of values for for x and y that gives: (a) 100% statement coverage (b) 100% branch coverage Source code • public int Fun1(int x, int y){ • k = 0; • while (x <= 10 && k < 10){ • if (x%2 != 0){ • k = k + y; • k = k – 2; • } • x = x + 1; • k = x + k; • } • if (x < 0){ • x = y; • k = k + x; • } • return k; • }
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
Summary cont • Unit Testing • Blackbox: equivalence partitioning and boundary analysis. • Whitebox: statement coverage, branch coverage. • Practice exercises were given for each testing technique.