SlideShare a Scribd company logo
1 of 19
Download to read offline
Property-based
Testing
Venkatesh-Prasad Ranganath
Kansas State University
Slides with * in title capture whiteboard content
Testing a sort function*
Given X[1:n], sort returns X ascending order as
R[1:m].
1. Ordering: for all 1 <= i < n, R[i] <= R[i+1]
2. Same Length: n == m [Redundant cosā€™ 3 implies
2]
3. Same Elements with Same Frequency:
1. If x in X, then x is in R and frequency(x, X) ==
frequency(x, R)
2. If x in R, then x is in X and frequency(x, R) ==
frequency(x, X)
What is a Property?*
ā€¢ A statement that is true of any (valid)
implementation of the speciļ¬cation
ā€¢ A full set of rules that embodies the speciļ¬cation
ā€¢ A singular expected behavior of the speciļ¬cation
ā€¢ an attribute, quality, or characteristic of something
(from a Dictionary)
From Springā€™16
What is a Property?*
ā€¢ Type of values
ā€¢ Some attributes of an UUT
ā€¢ Behavior, Structure, Shape
ā€¢ Holds for ā€œallā€ instances
ā€¢ Something that describes something
ā€¢ Attribute of a function that is consistent
independent of input
ā€¢ Concept that should be realized for something to
function as intended (Isnā€™t this speciļ¬cation?)
From Springā€™17
Properties for Identifying
Type of Triangle
You are given a Python function type_of_triangle(x, y, z) that
detects the type of triangle based on the lengths of its sides.
The function accepts the lengths of the sides of a triangle as
three integers x, y, and z and returns either "equilateral",
"isosceles", "scalene", or "not a triangle" depending on the type
of triangle formed by the input. The function assumes the input
parameters will be positive integers (>0). Further, the function
guarantees to return only one of the above four strings.
Identify the properties to test the correctness of this function. In
stating the properties, you may use the names x, y, and z to
denote the ļ¬rst, second, and third parameters of
type_of_triangle.
A. x == y == z
B. x == y != z or x == z != y or y == z != x
C. x != y != z
D. x+y > z and y+z > x and z+x > y
E. x > 0 and y > 0 and z > 0 (Assumed)
1. if A and D, then type_of_triangle(x,y,z) == ā€œequilateralā€
2. if B and D, then type_of_triangle(x,y,z) == ā€œisoscelesā€
3. if C and D, then type_of_triangle(x,y,z) == ā€œscaleneā€
4. if !D, then type_of_triangle(x,y,z) == ā€œnot a triangleā€
Properties for Identifying
Type of Triangle
1. If len() > 0 and x = pop(), then x was the last item
pushed and remove x from stack
2. If nothing has be placed on the stack, then len() =
0
3. Calls to successful push should increment length
by 1
4. Calls to successful (non-None) pop should
decrement length by 1
5. Popping an empty stack returns None
6. push(None) results in ValueError exception
Properties of a Stack*
Unamended properties from class possibly with redundancy.
7. n number of successful pushes followed by n
number of successful pops, values pushed should
be observed in reverse order when popped
8. len should always return non-negative integer
9. Popping and empty stack doesnā€™t change length
10.If len() > 0, then pop() return None
11.Length of stack equals to # of successful pushes -
# of successful pops
Properties of a Stack*
Unamended properties from class possibly with redundancy.
push(x)
bottom
len() == 0
pop() == None
len() == 0
bottom
x
len() == 1
bottom
Discovering Properties
involving Multiple Operations
bottom
ā€¦..
bottom
ā€¦..
x
push(x) pop() == x
bottom
ā€¦..
Discovering Properties
involving Multiple Operations
Discovering Properties
involving Multiple Operations
@given(st.integers())
def test_p1(x):
s = Stack()
s.push(x)
assert s.pop() == x
@given(st.lists(st.integers()), st.integers())
def test_p1(y, x):
s = Stack()
for i in y:
s.push(i)
s.push(x)
assert s.pop() == x
This test does not completely capture the
property ā€” it only considers newly created
Stacks.
This test completely captures the property
ā€” it considers any stack.
bottom
ā€¦..
bottom
ā€¦..
bottom
ā€¦..
x1
xk
x2
ā€¦..
push1(x1)
pushk(xk)
push2(x2)
ā€¦.
popk() ==x1
pop1() ==xk
popk-1() == x2
ā€¦.
Discovering Properties
involving Multiple Operations
bottom
ā€¦..
len() == n
bottom
ā€¦..
len() == n
push(x) When x == None
Discovering Properties
involving Multiple Operations
Results in ValueError
Exception
bottom
ā€¦..
len() == n
bottom
ā€¦..
len() == n + 1
xpush(x) When x != None
Discovering Properties
involving Multiple Operations
bottom
ā€¦..
len() == n
bottom
ā€¦..
x1
xk
x2
ā€¦..
push1(x1)
pushk(xk)
push2(x2)
ā€¦.
len() == n + k
When xi != None
Discovering Properties
involving Multiple Operations
bottom
ā€¦..
len() == n
bottom
ā€¦..
len() == n - 1
pop() != None
Discovering Properties
involving Multiple Operations
When n >= 1
When k <= n
bottom
ā€¦..
len() == n - k
xn-k
bottom
ā€¦..
xn-(k-1)
xn
xn-(k-2)
ā€¦..
popk() != None
pop1() != None
popk-1() != None
ā€¦.
len() == n
Discovering Properties
involving Multiple Operations
Ops
bottom
len() == 0
push1(x1)
push2(x2)
pushn(xn)
ā€¦.
Discovering Properties
involving Multiple Operations
len() == n
ā€¦..
bottom
len() == n
ā€¦..
bottom
len() == 0
bottom
len() == 0
bottom
pop1() == x1
pop2() == x2
popn() ==xn
ā€¦.
pop() == None
ā€¢ Ops is a sequence of push, pop, and len operations such that #push(y)
in Ops == #pop(z) in Ops
ā€¢ y != None
ā€¢ z != None
ā€¢ xi != None
any number of
push(None)
or len()
bottom
len() == 0
push1(x1)
push2(x2)
pushn(xn)
ā€¦.
Discovering Properties
involving Multiple Operations
len() == n
ā€¦..
bottom
len() == n
ā€¦..
bottom
len() == 0
bottom
len() == 0
bottom
pop1() == x1
pop2() == x2
popn() ==xn
ā€¦.
pop() == None
When xi != None

More Related Content

What's hot

Differentiation by first principles
Differentiation by first principlesDifferentiation by first principles
Differentiation by first principlessumanmathews
Ā 
Differential in several variables
Differential in several variables Differential in several variables
Differential in several variables Kum Visal
Ā 
Purely Functional Data Structures in Scala
Purely Functional Data Structures in ScalaPurely Functional Data Structures in Scala
Purely Functional Data Structures in ScalaVladimir Kostyukov
Ā 
1.6 inverse function (optional)
1.6 inverse function (optional)1.6 inverse function (optional)
1.6 inverse function (optional)math123c
Ā 
7.2 abs value function
7.2 abs value function7.2 abs value function
7.2 abs value functionMichael Cellini
Ā 
U1 Cn2 Functions
U1 Cn2 FunctionsU1 Cn2 Functions
U1 Cn2 FunctionsAlexander Burt
Ā 
Relations and functions
Relations and functions Relations and functions
Relations and functions Nabeel Simair
Ā 
Inverse functions
Inverse functionsInverse functions
Inverse functionsJJkedst
Ā 
Module 2 lesson 4 notes
Module 2 lesson 4 notesModule 2 lesson 4 notes
Module 2 lesson 4 notestoni dimella
Ā 
Lesson 19: Partial Derivatives
Lesson 19: Partial DerivativesLesson 19: Partial Derivatives
Lesson 19: Partial DerivativesMatthew Leingang
Ā 
Algebra 2 Section 2-3
Algebra 2 Section 2-3Algebra 2 Section 2-3
Algebra 2 Section 2-3Jimbo Lamb
Ā 
Inverse Functions
Inverse FunctionsInverse Functions
Inverse FunctionsAlexander Burt
Ā 
GATE Engineering Maths : Limit, Continuity and Differentiability
GATE Engineering Maths : Limit, Continuity and DifferentiabilityGATE Engineering Maths : Limit, Continuity and Differentiability
GATE Engineering Maths : Limit, Continuity and DifferentiabilityParthDave57
Ā 
Partial derivative1
Partial derivative1Partial derivative1
Partial derivative1Nidhu Sharma
Ā 
Notes - Graphs of Polynomials
Notes - Graphs of PolynomialsNotes - Graphs of Polynomials
Notes - Graphs of PolynomialsLori Rapp
Ā 
S1 3 derivadas_resueltas
S1 3 derivadas_resueltasS1 3 derivadas_resueltas
S1 3 derivadas_resueltasjesquerrev1
Ā 
Lesson 15: Inverse Functions And Logarithms
Lesson 15: Inverse Functions And LogarithmsLesson 15: Inverse Functions And Logarithms
Lesson 15: Inverse Functions And LogarithmsMatthew Leingang
Ā 
Inverse Functions
Inverse FunctionsInverse Functions
Inverse FunctionsJerri Harbison
Ā 

What's hot (18)

Differentiation by first principles
Differentiation by first principlesDifferentiation by first principles
Differentiation by first principles
Ā 
Differential in several variables
Differential in several variables Differential in several variables
Differential in several variables
Ā 
Purely Functional Data Structures in Scala
Purely Functional Data Structures in ScalaPurely Functional Data Structures in Scala
Purely Functional Data Structures in Scala
Ā 
1.6 inverse function (optional)
1.6 inverse function (optional)1.6 inverse function (optional)
1.6 inverse function (optional)
Ā 
7.2 abs value function
7.2 abs value function7.2 abs value function
7.2 abs value function
Ā 
U1 Cn2 Functions
U1 Cn2 FunctionsU1 Cn2 Functions
U1 Cn2 Functions
Ā 
Relations and functions
Relations and functions Relations and functions
Relations and functions
Ā 
Inverse functions
Inverse functionsInverse functions
Inverse functions
Ā 
Module 2 lesson 4 notes
Module 2 lesson 4 notesModule 2 lesson 4 notes
Module 2 lesson 4 notes
Ā 
Lesson 19: Partial Derivatives
Lesson 19: Partial DerivativesLesson 19: Partial Derivatives
Lesson 19: Partial Derivatives
Ā 
Algebra 2 Section 2-3
Algebra 2 Section 2-3Algebra 2 Section 2-3
Algebra 2 Section 2-3
Ā 
Inverse Functions
Inverse FunctionsInverse Functions
Inverse Functions
Ā 
GATE Engineering Maths : Limit, Continuity and Differentiability
GATE Engineering Maths : Limit, Continuity and DifferentiabilityGATE Engineering Maths : Limit, Continuity and Differentiability
GATE Engineering Maths : Limit, Continuity and Differentiability
Ā 
Partial derivative1
Partial derivative1Partial derivative1
Partial derivative1
Ā 
Notes - Graphs of Polynomials
Notes - Graphs of PolynomialsNotes - Graphs of Polynomials
Notes - Graphs of Polynomials
Ā 
S1 3 derivadas_resueltas
S1 3 derivadas_resueltasS1 3 derivadas_resueltas
S1 3 derivadas_resueltas
Ā 
Lesson 15: Inverse Functions And Logarithms
Lesson 15: Inverse Functions And LogarithmsLesson 15: Inverse Functions And Logarithms
Lesson 15: Inverse Functions And Logarithms
Ā 
Inverse Functions
Inverse FunctionsInverse Functions
Inverse Functions
Ā 

Similar to Property Based Testing [5] - Software Testing Techniques (CIS640)

L1 functions, domain &amp; range
L1 functions, domain &amp; rangeL1 functions, domain &amp; range
L1 functions, domain &amp; rangeJames Tagara
Ā 
Relations and Functions
Relations and FunctionsRelations and Functions
Relations and Functionstoni dimella
Ā 
Relations and Functions
Relations and FunctionsRelations and Functions
Relations and Functionstoni dimella
Ā 
Module 1 Lesson 1 Remediation Notes
Module 1 Lesson 1 Remediation NotesModule 1 Lesson 1 Remediation Notes
Module 1 Lesson 1 Remediation Notestoni dimella
Ā 
Functions for Grade 10
Functions for Grade 10Functions for Grade 10
Functions for Grade 10Boipelo Radebe
Ā 
3.1 Functions and Function Notation
3.1 Functions and Function Notation3.1 Functions and Function Notation
3.1 Functions and Function Notationsmiller5
Ā 
Mathsclass xii (exampler problems)
Mathsclass xii (exampler problems)Mathsclass xii (exampler problems)
Mathsclass xii (exampler problems)nitishguptamaps
Ā 
Rcommands-for those who interested in R.
Rcommands-for those who interested in R.Rcommands-for those who interested in R.
Rcommands-for those who interested in R.Dr. Volkan OBAN
Ā 
Introducing scala
Introducing scalaIntroducing scala
Introducing scalaMeetu Maltiar
Ā 
WEEK-2-FUNCTION-AND-RELATION-EVALAUTION-OF-A-FUNCTIONS.pptx
WEEK-2-FUNCTION-AND-RELATION-EVALAUTION-OF-A-FUNCTIONS.pptxWEEK-2-FUNCTION-AND-RELATION-EVALAUTION-OF-A-FUNCTIONS.pptx
WEEK-2-FUNCTION-AND-RELATION-EVALAUTION-OF-A-FUNCTIONS.pptxExtremelyDarkness2
Ā 
Scala Bootcamp 1
Scala Bootcamp 1Scala Bootcamp 1
Scala Bootcamp 1Knoldus Inc.
Ā 
Calculus - 1 Functions, domain and range
Calculus - 1 Functions, domain and rangeCalculus - 1 Functions, domain and range
Calculus - 1 Functions, domain and rangeIdrisJeffreyManguera
Ā 
02-04 Relations Functions
02-04 Relations Functions02-04 Relations Functions
02-04 Relations FunctionsBitsy Griffin
Ā 
Relations & Functions
Relations & FunctionsRelations & Functions
Relations & FunctionsBitsy Griffin
Ā 
General Mathematics - Representation and Types of Functions
General Mathematics - Representation and Types of FunctionsGeneral Mathematics - Representation and Types of Functions
General Mathematics - Representation and Types of FunctionsJuan Miguel Palero
Ā 
Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...
Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...
Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...Christian Robert
Ā 
Derivatives
DerivativesDerivatives
DerivativesNisarg Amin
Ā 

Similar to Property Based Testing [5] - Software Testing Techniques (CIS640) (20)

L1 functions, domain &amp; range
L1 functions, domain &amp; rangeL1 functions, domain &amp; range
L1 functions, domain &amp; range
Ā 
Relations and Functions
Relations and FunctionsRelations and Functions
Relations and Functions
Ā 
Relations and Functions
Relations and FunctionsRelations and Functions
Relations and Functions
Ā 
Module 1 Lesson 1 Remediation Notes
Module 1 Lesson 1 Remediation NotesModule 1 Lesson 1 Remediation Notes
Module 1 Lesson 1 Remediation Notes
Ā 
Functions for Grade 10
Functions for Grade 10Functions for Grade 10
Functions for Grade 10
Ā 
3.1 Functions and Function Notation
3.1 Functions and Function Notation3.1 Functions and Function Notation
3.1 Functions and Function Notation
Ā 
7 functions
7   functions7   functions
7 functions
Ā 
Functions
FunctionsFunctions
Functions
Ā 
Mathsclass xii (exampler problems)
Mathsclass xii (exampler problems)Mathsclass xii (exampler problems)
Mathsclass xii (exampler problems)
Ā 
Rcommands-for those who interested in R.
Rcommands-for those who interested in R.Rcommands-for those who interested in R.
Rcommands-for those who interested in R.
Ā 
Introducing scala
Introducing scalaIntroducing scala
Introducing scala
Ā 
WEEK-2-FUNCTION-AND-RELATION-EVALAUTION-OF-A-FUNCTIONS.pptx
WEEK-2-FUNCTION-AND-RELATION-EVALAUTION-OF-A-FUNCTIONS.pptxWEEK-2-FUNCTION-AND-RELATION-EVALAUTION-OF-A-FUNCTIONS.pptx
WEEK-2-FUNCTION-AND-RELATION-EVALAUTION-OF-A-FUNCTIONS.pptx
Ā 
Scala Bootcamp 1
Scala Bootcamp 1Scala Bootcamp 1
Scala Bootcamp 1
Ā 
Calculus - 1 Functions, domain and range
Calculus - 1 Functions, domain and rangeCalculus - 1 Functions, domain and range
Calculus - 1 Functions, domain and range
Ā 
02-04 Relations Functions
02-04 Relations Functions02-04 Relations Functions
02-04 Relations Functions
Ā 
Relations & Functions
Relations & FunctionsRelations & Functions
Relations & Functions
Ā 
General Mathematics - Representation and Types of Functions
General Mathematics - Representation and Types of FunctionsGeneral Mathematics - Representation and Types of Functions
General Mathematics - Representation and Types of Functions
Ā 
Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...
Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...
Statistics (1): estimation Chapter 3: likelihood function and likelihood esti...
Ā 
Derivatives
DerivativesDerivatives
Derivatives
Ā 
01 FUNCTIONS.pptx
01 FUNCTIONS.pptx01 FUNCTIONS.pptx
01 FUNCTIONS.pptx
Ā 

More from Venkatesh Prasad Ranganath

SeMA: A Design Methodology for Building Secure Android Apps
SeMA: A Design Methodology for Building Secure Android AppsSeMA: A Design Methodology for Building Secure Android Apps
SeMA: A Design Methodology for Building Secure Android AppsVenkatesh Prasad Ranganath
Ā 
Are free Android app security analysis tools effective in detecting known vul...
Are free Android app security analysis tools effective in detecting known vul...Are free Android app security analysis tools effective in detecting known vul...
Are free Android app security analysis tools effective in detecting known vul...Venkatesh Prasad Ranganath
Ā 
Benchpress: Analyzing Android App Vulnerability Benchmark Suites
Benchpress:  Analyzing Android App Vulnerability Benchmark SuitesBenchpress:  Analyzing Android App Vulnerability Benchmark Suites
Benchpress: Analyzing Android App Vulnerability Benchmark SuitesVenkatesh Prasad Ranganath
Ā 
Behavior Driven Development [10] - Software Testing Techniques (CIS640)
Behavior Driven Development [10] - Software Testing Techniques (CIS640)Behavior Driven Development [10] - Software Testing Techniques (CIS640)
Behavior Driven Development [10] - Software Testing Techniques (CIS640)Venkatesh Prasad Ranganath
Ā 
Code Coverage [9] - Software Testing Techniques (CIS640)
Code Coverage [9] - Software Testing Techniques (CIS640)Code Coverage [9] - Software Testing Techniques (CIS640)
Code Coverage [9] - Software Testing Techniques (CIS640)Venkatesh Prasad Ranganath
Ā 
Equivalence Class Testing [8] - Software Testing Techniques (CIS640)
Equivalence Class Testing [8] - Software Testing Techniques (CIS640)Equivalence Class Testing [8] - Software Testing Techniques (CIS640)
Equivalence Class Testing [8] - Software Testing Techniques (CIS640)Venkatesh Prasad Ranganath
Ā 
Boundary Value Testing [7] - Software Testing Techniques (CIS640)
Boundary Value Testing [7] - Software Testing Techniques (CIS640)Boundary Value Testing [7] - Software Testing Techniques (CIS640)
Boundary Value Testing [7] - Software Testing Techniques (CIS640)Venkatesh Prasad Ranganath
Ā 
Intro to Python3 [2] - Software Testing Techniques (CIS640)
Intro to Python3 [2] - Software Testing Techniques (CIS640)Intro to Python3 [2] - Software Testing Techniques (CIS640)
Intro to Python3 [2] - Software Testing Techniques (CIS640)Venkatesh Prasad Ranganath
Ā 
Unit testing [4] - Software Testing Techniques (CIS640)
Unit testing [4] - Software Testing Techniques (CIS640)Unit testing [4] - Software Testing Techniques (CIS640)
Unit testing [4] - Software Testing Techniques (CIS640)Venkatesh Prasad Ranganath
Ā 
Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)Venkatesh Prasad Ranganath
Ā 
Introduction [1] - Software Testing Techniques (CIS640)
Introduction [1] - Software Testing Techniques (CIS640)Introduction [1] - Software Testing Techniques (CIS640)
Introduction [1] - Software Testing Techniques (CIS640)Venkatesh Prasad Ranganath
Ā 
Compatibility Testing using Patterns-based Trace Comparison
Compatibility Testing using Patterns-based Trace ComparisonCompatibility Testing using Patterns-based Trace Comparison
Compatibility Testing using Patterns-based Trace ComparisonVenkatesh Prasad Ranganath
Ā 

More from Venkatesh Prasad Ranganath (17)

SeMA: A Design Methodology for Building Secure Android Apps
SeMA: A Design Methodology for Building Secure Android AppsSeMA: A Design Methodology for Building Secure Android Apps
SeMA: A Design Methodology for Building Secure Android Apps
Ā 
Are free Android app security analysis tools effective in detecting known vul...
Are free Android app security analysis tools effective in detecting known vul...Are free Android app security analysis tools effective in detecting known vul...
Are free Android app security analysis tools effective in detecting known vul...
Ā 
Benchpress: Analyzing Android App Vulnerability Benchmark Suites
Benchpress:  Analyzing Android App Vulnerability Benchmark SuitesBenchpress:  Analyzing Android App Vulnerability Benchmark Suites
Benchpress: Analyzing Android App Vulnerability Benchmark Suites
Ā 
Why do Users kill HPC Jobs?
Why do Users kill HPC Jobs?Why do Users kill HPC Jobs?
Why do Users kill HPC Jobs?
Ā 
Behavior Driven Development [10] - Software Testing Techniques (CIS640)
Behavior Driven Development [10] - Software Testing Techniques (CIS640)Behavior Driven Development [10] - Software Testing Techniques (CIS640)
Behavior Driven Development [10] - Software Testing Techniques (CIS640)
Ā 
Code Coverage [9] - Software Testing Techniques (CIS640)
Code Coverage [9] - Software Testing Techniques (CIS640)Code Coverage [9] - Software Testing Techniques (CIS640)
Code Coverage [9] - Software Testing Techniques (CIS640)
Ā 
Equivalence Class Testing [8] - Software Testing Techniques (CIS640)
Equivalence Class Testing [8] - Software Testing Techniques (CIS640)Equivalence Class Testing [8] - Software Testing Techniques (CIS640)
Equivalence Class Testing [8] - Software Testing Techniques (CIS640)
Ā 
Boundary Value Testing [7] - Software Testing Techniques (CIS640)
Boundary Value Testing [7] - Software Testing Techniques (CIS640)Boundary Value Testing [7] - Software Testing Techniques (CIS640)
Boundary Value Testing [7] - Software Testing Techniques (CIS640)
Ā 
Intro to Python3 [2] - Software Testing Techniques (CIS640)
Intro to Python3 [2] - Software Testing Techniques (CIS640)Intro to Python3 [2] - Software Testing Techniques (CIS640)
Intro to Python3 [2] - Software Testing Techniques (CIS640)
Ā 
Unit testing [4] - Software Testing Techniques (CIS640)
Unit testing [4] - Software Testing Techniques (CIS640)Unit testing [4] - Software Testing Techniques (CIS640)
Unit testing [4] - Software Testing Techniques (CIS640)
Ā 
Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)Testing concepts [3] - Software Testing Techniques (CIS640)
Testing concepts [3] - Software Testing Techniques (CIS640)
Ā 
Introduction [1] - Software Testing Techniques (CIS640)
Introduction [1] - Software Testing Techniques (CIS640)Introduction [1] - Software Testing Techniques (CIS640)
Introduction [1] - Software Testing Techniques (CIS640)
Ā 
Compatibility Testing using Patterns-based Trace Comparison
Compatibility Testing using Patterns-based Trace ComparisonCompatibility Testing using Patterns-based Trace Comparison
Compatibility Testing using Patterns-based Trace Comparison
Ā 
My flings with data analysis
My flings with data analysisMy flings with data analysis
My flings with data analysis
Ā 
Data analytics, a (short) tour
Data analytics, a (short) tourData analytics, a (short) tour
Data analytics, a (short) tour
Ā 
R language, an introduction
R language, an introductionR language, an introduction
R language, an introduction
Ā 
Pattern-based Features
Pattern-based FeaturesPattern-based Features
Pattern-based Features
Ā 

Recently uploaded

AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
Ā 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
Ā 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
Ā 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
Ā 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
Ā 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
Ā 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
Ā 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
Ā 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
Ā 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
Ā 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
Ā 
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø9953056974 Low Rate Call Girls In Saket, Delhi NCR
Ā 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
Ā 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
Ā 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
Ā 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
Ā 

Recently uploaded (20)

AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
Ā 
Model Call Girl in Tilak Nagar Delhi reach out to us at šŸ”9953056974šŸ”
Model Call Girl in Tilak Nagar Delhi reach out to us at šŸ”9953056974šŸ”Model Call Girl in Tilak Nagar Delhi reach out to us at šŸ”9953056974šŸ”
Model Call Girl in Tilak Nagar Delhi reach out to us at šŸ”9953056974šŸ”
Ā 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
Ā 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
Ā 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
Ā 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
Ā 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
Ā 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
Ā 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
Ā 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
Ā 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Ā 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
Ā 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
Ā 
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Kamla Market (DELHI) šŸ” >ą¼’9953330565šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
Ā 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
Ā 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
Ā 
Model Call Girl in Bikash Puri Delhi reach out to us at šŸ”9953056974šŸ”
Model Call Girl in Bikash Puri  Delhi reach out to us at šŸ”9953056974šŸ”Model Call Girl in Bikash Puri  Delhi reach out to us at šŸ”9953056974šŸ”
Model Call Girl in Bikash Puri Delhi reach out to us at šŸ”9953056974šŸ”
Ā 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Ā 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
Ā 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
Ā 

Property Based Testing [5] - Software Testing Techniques (CIS640)

  • 1. Property-based Testing Venkatesh-Prasad Ranganath Kansas State University Slides with * in title capture whiteboard content
  • 2. Testing a sort function* Given X[1:n], sort returns X ascending order as R[1:m]. 1. Ordering: for all 1 <= i < n, R[i] <= R[i+1] 2. Same Length: n == m [Redundant cosā€™ 3 implies 2] 3. Same Elements with Same Frequency: 1. If x in X, then x is in R and frequency(x, X) == frequency(x, R) 2. If x in R, then x is in X and frequency(x, R) == frequency(x, X)
  • 3. What is a Property?* ā€¢ A statement that is true of any (valid) implementation of the speciļ¬cation ā€¢ A full set of rules that embodies the speciļ¬cation ā€¢ A singular expected behavior of the speciļ¬cation ā€¢ an attribute, quality, or characteristic of something (from a Dictionary) From Springā€™16
  • 4. What is a Property?* ā€¢ Type of values ā€¢ Some attributes of an UUT ā€¢ Behavior, Structure, Shape ā€¢ Holds for ā€œallā€ instances ā€¢ Something that describes something ā€¢ Attribute of a function that is consistent independent of input ā€¢ Concept that should be realized for something to function as intended (Isnā€™t this speciļ¬cation?) From Springā€™17
  • 5. Properties for Identifying Type of Triangle You are given a Python function type_of_triangle(x, y, z) that detects the type of triangle based on the lengths of its sides. The function accepts the lengths of the sides of a triangle as three integers x, y, and z and returns either "equilateral", "isosceles", "scalene", or "not a triangle" depending on the type of triangle formed by the input. The function assumes the input parameters will be positive integers (>0). Further, the function guarantees to return only one of the above four strings. Identify the properties to test the correctness of this function. In stating the properties, you may use the names x, y, and z to denote the ļ¬rst, second, and third parameters of type_of_triangle.
  • 6. A. x == y == z B. x == y != z or x == z != y or y == z != x C. x != y != z D. x+y > z and y+z > x and z+x > y E. x > 0 and y > 0 and z > 0 (Assumed) 1. if A and D, then type_of_triangle(x,y,z) == ā€œequilateralā€ 2. if B and D, then type_of_triangle(x,y,z) == ā€œisoscelesā€ 3. if C and D, then type_of_triangle(x,y,z) == ā€œscaleneā€ 4. if !D, then type_of_triangle(x,y,z) == ā€œnot a triangleā€ Properties for Identifying Type of Triangle
  • 7. 1. If len() > 0 and x = pop(), then x was the last item pushed and remove x from stack 2. If nothing has be placed on the stack, then len() = 0 3. Calls to successful push should increment length by 1 4. Calls to successful (non-None) pop should decrement length by 1 5. Popping an empty stack returns None 6. push(None) results in ValueError exception Properties of a Stack* Unamended properties from class possibly with redundancy.
  • 8. 7. n number of successful pushes followed by n number of successful pops, values pushed should be observed in reverse order when popped 8. len should always return non-negative integer 9. Popping and empty stack doesnā€™t change length 10.If len() > 0, then pop() return None 11.Length of stack equals to # of successful pushes - # of successful pops Properties of a Stack* Unamended properties from class possibly with redundancy.
  • 9. push(x) bottom len() == 0 pop() == None len() == 0 bottom x len() == 1 bottom Discovering Properties involving Multiple Operations
  • 10. bottom ā€¦.. bottom ā€¦.. x push(x) pop() == x bottom ā€¦.. Discovering Properties involving Multiple Operations
  • 11. Discovering Properties involving Multiple Operations @given(st.integers()) def test_p1(x): s = Stack() s.push(x) assert s.pop() == x @given(st.lists(st.integers()), st.integers()) def test_p1(y, x): s = Stack() for i in y: s.push(i) s.push(x) assert s.pop() == x This test does not completely capture the property ā€” it only considers newly created Stacks. This test completely captures the property ā€” it considers any stack.
  • 13. bottom ā€¦.. len() == n bottom ā€¦.. len() == n push(x) When x == None Discovering Properties involving Multiple Operations Results in ValueError Exception
  • 14. bottom ā€¦.. len() == n bottom ā€¦.. len() == n + 1 xpush(x) When x != None Discovering Properties involving Multiple Operations
  • 15. bottom ā€¦.. len() == n bottom ā€¦.. x1 xk x2 ā€¦.. push1(x1) pushk(xk) push2(x2) ā€¦. len() == n + k When xi != None Discovering Properties involving Multiple Operations
  • 16. bottom ā€¦.. len() == n bottom ā€¦.. len() == n - 1 pop() != None Discovering Properties involving Multiple Operations When n >= 1
  • 17. When k <= n bottom ā€¦.. len() == n - k xn-k bottom ā€¦.. xn-(k-1) xn xn-(k-2) ā€¦.. popk() != None pop1() != None popk-1() != None ā€¦. len() == n Discovering Properties involving Multiple Operations
  • 18. Ops bottom len() == 0 push1(x1) push2(x2) pushn(xn) ā€¦. Discovering Properties involving Multiple Operations len() == n ā€¦.. bottom len() == n ā€¦.. bottom len() == 0 bottom len() == 0 bottom pop1() == x1 pop2() == x2 popn() ==xn ā€¦. pop() == None ā€¢ Ops is a sequence of push, pop, and len operations such that #push(y) in Ops == #pop(z) in Ops ā€¢ y != None ā€¢ z != None ā€¢ xi != None
  • 19. any number of push(None) or len() bottom len() == 0 push1(x1) push2(x2) pushn(xn) ā€¦. Discovering Properties involving Multiple Operations len() == n ā€¦.. bottom len() == n ā€¦.. bottom len() == 0 bottom len() == 0 bottom pop1() == x1 pop2() == x2 popn() ==xn ā€¦. pop() == None When xi != None