Com1040 Systems Design and Testing Part II – Testing (Based on A.J. Cowling’s lecture notes) LN-Test3: Equivalence classes and boundary conditions Marian.

Slides:



Advertisements
Similar presentations
Overview Functional Testing Boundary Value Testing (BVT)
Advertisements

Equivalence Class Testing
Sets Lecture 11: Oct 24 AB C. This Lecture We will first introduce some basic set theory before we do counting. Basic Definitions Operations on Sets Set.
CSE 143 Lecture 4: testing and complexity reading:
Software Testing and Quality Assurance
1 Lecture 23 Decision problems about regular languages –Programs can be inputs to other programs FSA’s, NFA’s, regular expressions –Basic problems are.
Testing an individual module
EXAMPLE 1 Classifying a Triangle a.Classify XYZ by its angles. b. Classify XYZ by its side lengths. SOLUTION a. The triangle has a right angle at Y. So,
HOW MANY SIDES ARE THERE, AND WHAT IS THEIR ANGLE?
Equivalence Class Testing
Black Box Software Testing
1 Functional Testing Motivation Example Basic Methods Timing: 30 minutes.
CMSC 345 Fall 2000 Unit Testing. The testing process.
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
5-1 Classifying Triangles Today we will be learning how to classify triangles according to length of sides and measurement of the angles.
Requirements-based Test Generation for Functional Testing (© 2012 Professor W. Eric Wong, The University of Texas at Dallas) 1 W. Eric Wong Department.
Software Testing. 2 CMSC 345, Version 4/12 Topics The testing process  unit testing  integration and system testing  acceptance testing Test case planning.
Sets --- A set is a collection of objects. Sets are denoted by A, B, C, … --- The objects in the set are called the elements of the set. The elements are.
CS 61B Data Structures and Programming Methodology July 28, 2008 David Sun.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
Summarizing “Structural” Testing Now that we have learned to create test cases through both: – a) Functional (blackbox)and – b) Structural (whitebox) testing.
Today’s Agenda  Reminder: HW #1 Due next class  Quick Review  Input Space Partitioning Software Testing and Maintenance 1.
Com1040 Systems Design and Testing Part II – Testing (Based on A.J. Cowling’s lecture notes) LN-Test4: Category-Partition Method Marian Gheorghe ©University.
Lecture 2 Examples Pseudo code and flowcharts. Problem 1 Read a number as input and then print if it is even or odd.
Triangle A polygon with three sides and three angles. A triangle can be names by its’ side lengths and angles. – Side lengths: isosceles, equilateral,
EXAMPLE 1 Standardized Test Practice SOLUTION Let ( x 1, y 1 ) = ( –3, 5) and ( x 2, y 2 ) = ( 4, – 1 ). = (4 – (–3)) 2 + (– 1 – 5) 2 = = 85 (
Com1040 Systems Design and Testing Part II – Testing (Based on A.J. Cowling’s lecture notes) LN-Test1+2: Introduction to Testing Marian Gheorghe ©University.
TRIANGLES AND TYPES OF TRIANGLES. A triangle has three sides.
Triangles 1st year P26 Chapter 4.
Types of Triangles. Angles The angles in a triangle add up to o + 60 o + 60 o =
Equivalence Class Testing In chapter 5, we saw that all four variations of boundary value testing are vulnerable to –gaps of untested functionality, and.
Exploring Angles in a Triangles Chapter 8 Lesson 4 Image Taken from:
Triangles Shapes with 3 sides! Equilateral Triangle All 3 Sides are equal in Length All 3 interior angles are the same.
Testing Data Structures Tao Xie Visiting Professor, Peking University Associate Professor, North Carolina State University
Theory and Practice of Software Testing Chapter 14 Presman Software Testing Tactics BLACK BOX TESTING.
Warm Up If you add two even numbers do you always get an even number? If you add two odd numbers do you always get an odd number.
Com1040 Systems Design and Testing Part II – Testing (Based on A.J. Cowling’s lecture notes) LN-Test5: Category-Partition Method Marian Gheorghe ©University.
Review. Problem 1 What is the output of the following piece of code void increment(int x) { x++; } int main() { int y = 10; increment(y); cout
1 © 2011 Professor W. Eric Wong, The University of Texas at Dallas Requirements-based Test Generation for Functional Testing W. Eric Wong Department of.
1 Software Testing. 2 Equivalence Class Testing 3 The use of equivalence class testing has two motivations: –Sense of complete testing –Avoid redundancy.
Time for Triangles. What is a triangle? A triangle is a polygon. It has 3 sides and 3 angles. It can also be called a trigon.
Equivalence Class Testing Use the mathematical concept of partitioning into equivalence classes to generate test cases for Functional (Black-box) testing.
Set Operations Section 2.2.
Triangle Review A scalene triangle has no sides and no angles equal. An isosceles triangle has two sides and two angles equal. An equilateral triangle.
Classifying Triangles Lesson Classifying by Angle Acute triangles have three acute angles. Obtuse triangles have one obtuse angle. Right triangles.
Classifying Triangles. Two Ways to Classify Triangles  By Their Sides  By Their Angles.
Lesson 8.3 Concept: How to classify triangles by their sides and angles. An equilateral triangle has three sides of the same length. An isosceles triangle.
Learning Objective Identify triangles using their sides.
Dynamic Black-Box Testing Part 1 What is dynamic black-box testing? How to reduce the number of test cases using: Equivalence partitioning Boundary value.
5-1 Classifying Triangles
Testing Data Structures
Geometry Part 1 LINES LINE SEGMENTS RAYS.
Input Space Partition Testing CS 4501 / 6501 Software Testing
MCC.4.G.1-2 All About Triangles.
Classifying Triangles
Classifying Triangles
Overview Functional Testing Boundary Value Testing (BVT)
Geometry.
Equivalence Class Testing
1.6) Storing Integer:.
In conclusion... Same shape, same size Same shape, different size
Classifying Triangles
Objective - To classify triangles.
Directions: Cut out each of the triangles below
Classifying Triangles
Overview Functional Testing Boundary Value Testing (BVT)
CS100J Lecture 16 Previous Lecture This Lecture Programming concepts
Intro to Triangles.
CS100J Lecture 16 Previous Lecture This Lecture Programming concepts
4-1 Classifying Triangles
Presentation transcript:

Com1040 Systems Design and Testing Part II – Testing (Based on A.J. Cowling’s lecture notes) LN-Test3: Equivalence classes and boundary conditions Marian Gheorghe ©University of SheffieldCom Testing

Equivalence partition Boundary conditions Examples Specification-based testing Summary

Equivalence classes and boundaries Entities (variables) of a program have certain ranges of values – data sets, given by their types Data set boundaries are either explicitly defined in the application or provided by the programming language constructs or the programming environment Let us consider an entity e and its range min..Max Observations min, Max may be (1) implicitly introduced (minimum and maximum entity value – integers, reals; or empty set for various collections etc) or (2) may have defined values (maybe within implicitly defined range) testing will identify equivalence classes and may add boundary conditions around min and Max test set depends on the input set and the program under test

This example requires to check whether a given value belongs to a set of integers (either consecutive values or indexed by an array index). The integers form a range between min, the minimum value and Max, the maximum The equivalence classes are: { min } { Max } values from the set, but different from min and Max values outside the range (within [-2 n-1..2 n-1 ], n digits rep) Around boundary; new tests: min + ind, Max – ind ; where ind provides the next or previous element Test set has 6 elements = 4 partitions + 2 new boundaries Building partitions and boundaries is not always obvious… Example – partition and boundaries

Triangle example revisited The program accepts three positive whole numbers as lengths of the sides of a triangle and classifies the triangle according to its shape, equilateral, isosceles, scalene or returns impossible when there is no triangle. int triangle(int a, int b, int c) { int mx, x, y; mx = a; x = b; y = c; if (mx < b) {x = mx; mx = b;} if (mx < c) {y = mx; mx = c;} if (mx >= x + y) {return 4; // impossible} if (a == b && b == c) {return 1; // equilateral} if (a == b || b == c || a == c) {return 2; // isosceles} return 3; // scalene } Find maximum Answer

Build a test set using partitions and boundary values for the white box testing approach The range of input vales: D = N  N  N, N is the set of positive integers; D  D ext =Z  Z  Z, Z stands for integers Partitions are: Eq={(a,b,c)| a,b,c  N;a==b&&b==c} Is={(a,b,c)| a,b,c  N;a==b||b==c||a==c, (a,b,c)  Eq} Sc={(a,b,c)| a,b,c  N;(a,b,c)  Eq  Is} Im={(a,b,c)| a,b,c  N;(a,b,c)  Eq  Is  Sc} Other values - a,b,c with negative values, including 0? Boundary values? The test set with 4 values: representatives of Eq - (3,3,3), Is - (30,40,30), Sc – (3,5,7), Im – (6,10,2) Note: more than one partition in the range of input values Triangle example - partitions

public class TriangleClass { public static int triangle(int a, int b, int c) //… your code } // other methods } public class TestTriangle public void Equilateral() { assertEquals(1, TriangleClass.triangle(3,3,3), 0); } // other tests … } Triangle unit testing

public class TriangleClass { public static int triangle(int a, int b, int c) //… your code } // other methods } public class TestTriangle public void Equilateral() { assertEquals(1, TriangleClass.triangle(3,3,3), 0); } // other tests … } What else? Triangle unit testing

public class TriangleClass { public static int triangle(int a, int b, int c) //… your code } // other methods } public class TestTriangle public void Equilateral() { assertEquals(1, TriangleClass.triangle(3,3,3), 0); } // other tests … } Do we need to test the part computing the maximum value? Triangle unit testing

Triangle example – specification based We aim to generate test sets based on this specification: The program accepts three positive whole numbers as lengths of the sides of a triangle and classifies the triangle according to its shape, equilateral, isosceles, scalene or returns impossible when there is no triangle. The partitions generated above, Eq, Is, Sc, Im are utilised – they cover just D

Triangle example – specification based (2) We aim to generate test sets based on this specification: The program accepts three positive whole numbers as lengths of the sides of a triangle and classifies the triangle according to its shape, equilateral, isosceles, scalene or returns impossible when there is no triangle. The partitions generated above, Eq, Is, Sc, Im are utilised – they cover just D Other partitions:?

Triangle example – specification based (2) We aim to generate test sets based on this specification: The program accepts three positive whole numbers as lengths of the sides of a triangle and classifies the triangle according to its shape, equilateral, isosceles, scalene or returns impossible when there is no triangle. The partitions generated above, Eq, Is, Sc, Im are utilised – they cover just D Other partitions: D ext - D (excluding boundaries of D - outside D) – negative values and combinations: 3 with a -, 3 with -,- and (-,-,-),

Triangle example – specification based (3) We aim to generate test sets based on this specification: The program accepts three positive whole numbers as lengths of the sides of a triangle and classifies the triangle according to its shape, equilateral, isosceles, scalene or returns impossible when there is no triangle. The partitions generated above, Eq, Is, Sc, Im are utilised – they cover just D Other partitions: D ext - D (excluding boundaries of D - outside D) – negative values and combinations: 3 with a -, 3 with -,- and (-,-,-), Boundary conditions?

Triangle example – specification based (3) We aim to generate test sets based on this specification: The program accepts three positive whole numbers as lengths of the sides of a triangle and classifies the triangle according to its shape, equilateral, isosceles, scalene or returns impossible when there is no triangle. The partitions generated above, Eq, Is, Sc, Im are utilised – they cover just D Other partitions: D ext - D (excluding boundaries of D - outside D) – negative values and combinations: 3 with a -, 3 with -,- and (-,-,-), Boundary conditions: 0’s as side lengths – 7 more Test set with test cases… some more might be considered navigating around boundary values by adding  1 at each component of every test case involved in checking boundaries (6+8  3+8  3 more)

Chunks of input data (1)Input data may occur at different instances in time Example. Given two sets, A and B, of integer values between min and Max, we aim to check whether there is any relationship between A and B (equality – A=B; inclusion - A  B, A  B; non-empty intersection - A  B  ). If A and B contain values outside the range then return 0, otherwise 1; for each of the above relationships, return an answer between For sets A and B containing elements from the above range, such that the non-empty intersection holds, we should get 15; for a relationship non listed, 1, should be produced.  considered valid set. Two stages: (1) check that A, B contain elements between min and Max ; (2) check the relationship between A and B. The testing guided by A, B within min..Max A, B not in min..Max A, B relationship

Test set: partitions and boundaries (1.1) A, B contain all elements from min.. Max: , set with one element and set with arbitrary number of elements; in the last two cases consider boundaries, min, Max  9 +8  2 (either min or Max ) +6 (both min, Max ) =31 cases (1.2) A, B contain elements outside of min.. Max: exercise (2.1) Relationships between A and B: for each of the (1.1) case consider all the defined relationships. But, they are not independent – some redundant and others not appropriate. So, we need a more refined analysis. Let us consider A=B: (1)  =  ; (2) one element set, including boundaries – 3 cases; (3) arbitrary sets including boundaries – 2 elements;  total of 6; similarly for other relationships. Consequently, we keep the (1.1) 31 cases only for no relationship. (2.2) is empty as it shows the diagram below A, B within min..Max A, B not in min..Max A, B relationship

Equivalence partitions and boundary conditions Both applied for implementation- and specification-based unit testing Some general rules can be identified, but optimisations are expected Conclusions