SlideShare a Scribd company logo
1 of 36
Download to read offline
Making property-based testing
easier to read for humans
Laura M. Castro
February 18th, 2016
Stakeholder involvement & software testing
The challenge of communication
Active stakeholder participation is an agile best practice1
Early testing is also an agile best practice1
1
Agile practices are considered mainstream, with adoption rates ≈50%2 of 30
Stakeholder involvement & software testing
The challenge of communication
Active stakeholder participation is an agile best practice1
stakeholder involvement requires inclusive modeling
(UML activity diagrams, user stories)
Early testing is also an agile best practice1
best represented by Test-Driven Development (TDD)
1
Agile practices are considered mainstream, with adoption rates ≈50%2 of 30
Stakeholder involvement & software testing
The challenge of communication
Active stakeholder participation is an agile best practice1
stakeholder involvement requires inclusive modeling
(UML activity diagrams, user stories)
Early testing is also an agile best practice1
best represented by Test-Driven Development (TDD)
stakeholder involvement + early testing =
Behaviour-Driven Development (BDD)
1
Agile practices are considered mainstream, with adoption rates ≈50%2 of 30
Behaviour-Driven Development
Feature: Deletion of element from list
In order to operate lists
As a user of the lists module
I want to delete an element from a list
Scenario: Delete integer from list of integers
Given I have the integer 3
And I have the list of integers [0,8,6]
When I use the function lists:delete/2
Then the resulting list should not contain 3
3 of 30
Behaviour-Driven Development
The behaviour becomes test case
given("I have the integer (d+)", S, [Num]) ->
{ok, S ++ [list_to_integer(Num)]};
...
when("I use the function (w+) from the module (w+)", S, [F, M]) ->
{ok, apply(list_to_atom(M), list_to_atom(F), S)}.
then("the resulting list should not contain (d+)", S, [Num]) ->
case not lists:member(list_to_integer(Num), S) of
true -> {ok, S};
false -> {failed, S}
end.
4 of 30
Behaviour-Driven Development
Is this catching on?
5 of 30
Behaviour-Driven Development
Is this catching on?
6 of 30
Behaviour-Driven Development
Pros and cons
Good as communication tool
a number of implementations in many languages:
C++, Clojure, Erlang, Java, JavaScript, Lua, .NET, PHP,…
Not as good as testing tool
run as many test cases as you can write
well-known problems of “traditional” testing:
specification, implementation, maintainability, effectiveness
7 of 30
Property-Based Testing (PBT)
Strategy for improved testing: abstraction + automation
write properties instead of test cases
properties are used to automatically
generate, run, and diagnose many, many test cases
8 of 30
Property-Based Testing
A very simple example
How do you write properties? Let’s start simple:
Example: delete an element from a list
9 of 30
Property-Based Testing
A very simple example
How do you write properties? Let’s start simple:
Example: delete an element from a list
Desired functionality?
If I delete an element from a list,
it shouldn't be there anymore.
9 of 30
Property-Based Testing
A very simple example
How do you write properties? Let’s start simple:
Example: delete an element from a list
Desired functionality?
If I delete an element from a list,
it shouldn't be there anymore.
Which item? Which list? Any.
9 of 30
Property-Based Testing
A very simple example
prop_simple() ->
?FORALL(I, item(),
?FORALL(L, list(item()),
not lists:member(I, lists:delete(I, L)))).
10 of 30
Property-Based Testing
A very simple example
prop_simple() ->
?FORALL(I, item(),
?FORALL(L, list(item()),
not lists:member(I, lists:delete(I, L)))).
11 of 30
Property-Based Testing
A very simple example
prop_simple() ->
?FORALL(I, item(),
?FORALL(L, list(item()),
not lists:member(I, lists:delete(I, L)))).
12 of 30
Property-Based Testing
A very simple example
prop_simple() ->
?FORALL(I, item(),
?FORALL(L, list(item()),
[] == [ X || X <- lists:delete(I, L), X == I])).
13 of 30
Property-Based Testing
A very simple example
prop_simple() ->
?FORALL(I, item(),
?FORALL(L, list(item()),
not lists:member(I, lists:delete(I, L)))).
14 of 30
Property-Based Testing
A very simple example
> eqc:quickcheck(simple_eqc:prop_simple()).
................................................
................................................
....
OK, passed 100 tests
15 of 30
Property-Based Testing
A very simple example
> eqc:quickcheck(simple_eqc:prop_simple()).
................................................
.................... Failed! After 69 tests.
15
[-13,-15,-2,-17,-20,15,15]
Shrinking xxxxxxxx.xx.xxxxxxxx (2 times)
15
[15,15]
16 of 30
Property-Based Testing
A more complex example
How complex can it get? Models for stateful components.
Example: EVM registry
register(Name, Pid) -> ok
unregister(Name) -> ok
whereis(Name) -> Pid | undefined
17 of 30
Property-Based Testing
A more complex example
How complex can it get? Models for stateful components.
Example: EVM registry
register(Name, Pid) -> ok
unregister(Name) -> ok
whereis(Name) -> Pid | undefined
Desired functionality?
If I perform a sequence of registry actions,
I expect compliance with model at all times.
17 of 30
Property-Based Testing
A more complex example
How complex can it get? Models for stateful components.
Example: EVM registry
register(Name, Pid) -> ok
unregister(Name) -> ok
whereis(Name) -> Pid | undefined
Desired functionality?
If I perform a sequence of registry actions,
I expect compliance with model at all times.
Which sequences of actions? Any.
17 of 30
Property-Based Testing
A more complex example
prop_registry() ->
?FORALL(Cmds, commands(registry_model),
begin
... % setup code
{H, S, TResult} = run_commands(registry_model,Cmds),
... % cleanup code
TResult == ok
end).
18 of 30
Property-Based Testing
A more complex example
prop_registry() ->
?FORALL(Cmds, commands(registry_model),
begin
... % setup code
{H, S, TResult} = run_commands(registry_model,Cmds),
... % cleanup code
TResult == ok
end).
19 of 30
Property-Based Testing
A more complex example
register_pre(S) ->
S#state.pids /= [].
...
unregister_next(S,_,[Name]) ->
S#state{regs = lists:keydelete(Name,1,S#state.regs)}.
...
whereis_post(S, [Name], Result) ->
case lists:keyfind(Name, 1, S#state.regs) of
{Name,Value} -> Res =:= Value;
false -> Res =:= undefined
end.
20 of 30
Property-Based Testing
Pros and cons
Good as testing tool
run as many test cases as you have time to execute
run different test cases every time
get reduced counterexamples, for focused debugging
get a functional specification of the software
a number of implementations in many languages:
Clojure, Lisp, Erlang, ML, Prolog, Scala, Scheme, Smalltalk,…
Not as good as communication tool
21 of 30
readSpec
making PBT easier to read for humans
Get (semi)natural language descriptions
for sample test cases that test properties produce
1. Write PBT artifacts (properties, models)
2. Get readSpec to translate them into cucumber-like features
implemented in Erlang
uses Quviq QuickCheck’s coverage-based suite generation
Available at:
https://github.com/prowessproject/readspec
22 of 30
readSpec
A very simple example: what do you get?
File: simple.feature
FEATURE: simple
Simple QuickCheck properties
...
SCENARIO: Deleting an integer from a list should
result in a list that does not contain that integer.
GIVEN I have the integer 6
AND I have the list [-1, 2, 13, 0, 5]
THEN IS FALSE THAT the integer 6 is in
the result of calling lists:delete/2
with 6 and [-1, 2, 13, 0, 5].
...
23 of 30
readSpec
A very simple example: what do you get?
File: prop_simple.counterexample.feature
GIVEN I have the integer 15
AND I have the list [15, 15]
THEN the integer 15 is in
the result of calling lists:delete/2 with 15 and [15, 15].
24 of 30
readSpec
A very simple example: what do you get?
**********************************************************
CALL: register/2
**********************************************************
POSSIBILITIES ...
================================
*** REQUIREMENTS ***
[*] The field called "pids" must be equal to the empty list
*** RESULT ***
the literal 'false'
================================
OTHERWISE ...
================================
*** RESULT ***
the literal 'true'
25 of 30
VoDKATV: industrial pilot study
26 of 30
VoDKATV: industrial pilot study
Research questions
RQ 1) Can readSpec produce efficient text representations of
test properties?
RQ 2) Are readSpec text representations an effective way to
communicate among stakeholders?
27 of 30
VoDKATV: industrial pilot study
Measurements
RQ 1) Amount of time to generate the textual representation
RQ 1) LOC of textual representations w.r.t.
LOC of corresponding test properties/models
RQ 2) Stakeholders average rating of usefulness
(would use them instead of current way of communic.?)
RQ 2) Stakeholders average rating of usability
(appropriate? easy to understand/follow?)
28 of 30
VoDKATV: industrial pilot study
Results
Amount of time needed in the order of milliseconds
Nature of output (verbosity, number of lines) appropriate
Simple cases: high degree of influence of personal skills and
background on deeming text more helpful than property code
Complex cases: some people still cannot make sense of
either; the rest consistently agree the text is more helpful
enough to provide the insights needed to suggest more tests!
29 of 30
readSpec: making PBT easier to read for humans
Final quotes
“readSpec looks human-friendly”
“simple cases are too verbose for tech people (code is shorter)”
“helps in understanding tests better, especially when they’re complex”
“it’s interesting when cases reach certain complexity”
“presents requirements in an explicit way, that can slip your mind o/w”
“this is very helpful for people who are not familiar with the code”
“only with a good level of maturity and experience one could be more
comfortable with QC properties and models”
30 of 30

More Related Content

What's hot

A Natural Language Programming Approach for Requirements-based Security Testing
A Natural Language Programming Approach for Requirements-based Security TestingA Natural Language Programming Approach for Requirements-based Security Testing
A Natural Language Programming Approach for Requirements-based Security TestingLionel Briand
 
Automated and Scalable Solutions for Software Testing: The Essential Role of ...
Automated and Scalable Solutions for Software Testing: The Essential Role of ...Automated and Scalable Solutions for Software Testing: The Essential Role of ...
Automated and Scalable Solutions for Software Testing: The Essential Role of ...Lionel Briand
 
findbugs Bernhard Merkle
findbugs Bernhard Merklefindbugs Bernhard Merkle
findbugs Bernhard Merklebmerkle
 
An Approach to Software Testing of Machine Learning Applications
An Approach to Software Testing of Machine Learning ApplicationsAn Approach to Software Testing of Machine Learning Applications
An Approach to Software Testing of Machine Learning Applicationsbutest
 
SBST 2019 Keynote
SBST 2019 Keynote SBST 2019 Keynote
SBST 2019 Keynote Shiva Nejati
 
Transferring Software Testing Tools to Practice (AST 2017 Keynote)
Transferring Software Testing Tools to Practice (AST 2017 Keynote)Transferring Software Testing Tools to Practice (AST 2017 Keynote)
Transferring Software Testing Tools to Practice (AST 2017 Keynote)Tao Xie
 
Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...
Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...
Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...fabriziopastore
 
Code coverage based test case selection and prioritization
Code coverage based test case selection and prioritizationCode coverage based test case selection and prioritization
Code coverage based test case selection and prioritizationijseajournal
 
Finding bugs that matter with Findbugs
Finding bugs that matter with FindbugsFinding bugs that matter with Findbugs
Finding bugs that matter with FindbugsCarol McDonald
 
Diversity Maximization Speedup for Fault Localization
Diversity Maximization Speedup for Fault LocalizationDiversity Maximization Speedup for Fault Localization
Diversity Maximization Speedup for Fault LocalizationLiang Gong
 
Istqb ctfl-series - Black Box Testing
Istqb ctfl-series - Black Box TestingIstqb ctfl-series - Black Box Testing
Istqb ctfl-series - Black Box TestingDisha Srivastava
 
Amin Milani Fard: Directed Model Inference for Testing and Analysis of Web Ap...
Amin Milani Fard: Directed Model Inference for Testing and Analysis of Web Ap...Amin Milani Fard: Directed Model Inference for Testing and Analysis of Web Ap...
Amin Milani Fard: Directed Model Inference for Testing and Analysis of Web Ap...knowdiff
 
Software Testing Techniques
Software Testing TechniquesSoftware Testing Techniques
Software Testing TechniquesKiran Kumar
 
Advances in Unit Testing: Theory and Practice
Advances in Unit Testing: Theory and PracticeAdvances in Unit Testing: Theory and Practice
Advances in Unit Testing: Theory and PracticeTao Xie
 

What's hot (20)

A Natural Language Programming Approach for Requirements-based Security Testing
A Natural Language Programming Approach for Requirements-based Security TestingA Natural Language Programming Approach for Requirements-based Security Testing
A Natural Language Programming Approach for Requirements-based Security Testing
 
10 software testing_technique
10 software testing_technique10 software testing_technique
10 software testing_technique
 
Automated and Scalable Solutions for Software Testing: The Essential Role of ...
Automated and Scalable Solutions for Software Testing: The Essential Role of ...Automated and Scalable Solutions for Software Testing: The Essential Role of ...
Automated and Scalable Solutions for Software Testing: The Essential Role of ...
 
findbugs Bernhard Merkle
findbugs Bernhard Merklefindbugs Bernhard Merkle
findbugs Bernhard Merkle
 
Sta unit 3(abimanyu)
Sta unit 3(abimanyu)Sta unit 3(abimanyu)
Sta unit 3(abimanyu)
 
SAIConference_PAPER
SAIConference_PAPERSAIConference_PAPER
SAIConference_PAPER
 
An Approach to Software Testing of Machine Learning Applications
An Approach to Software Testing of Machine Learning ApplicationsAn Approach to Software Testing of Machine Learning Applications
An Approach to Software Testing of Machine Learning Applications
 
SBST 2019 Keynote
SBST 2019 Keynote SBST 2019 Keynote
SBST 2019 Keynote
 
Transferring Software Testing Tools to Practice (AST 2017 Keynote)
Transferring Software Testing Tools to Practice (AST 2017 Keynote)Transferring Software Testing Tools to Practice (AST 2017 Keynote)
Transferring Software Testing Tools to Practice (AST 2017 Keynote)
 
Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...
Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...
Mutation Analysis and Testing for Cyber-Physical Systems: Scalable Solutions...
 
Code coverage based test case selection and prioritization
Code coverage based test case selection and prioritizationCode coverage based test case selection and prioritization
Code coverage based test case selection and prioritization
 
Black Box Testing
Black Box TestingBlack Box Testing
Black Box Testing
 
Sta unit 2(abimanyu)
Sta unit 2(abimanyu)Sta unit 2(abimanyu)
Sta unit 2(abimanyu)
 
Finding bugs that matter with Findbugs
Finding bugs that matter with FindbugsFinding bugs that matter with Findbugs
Finding bugs that matter with Findbugs
 
Diversity Maximization Speedup for Fault Localization
Diversity Maximization Speedup for Fault LocalizationDiversity Maximization Speedup for Fault Localization
Diversity Maximization Speedup for Fault Localization
 
Rv11
Rv11Rv11
Rv11
 
Istqb ctfl-series - Black Box Testing
Istqb ctfl-series - Black Box TestingIstqb ctfl-series - Black Box Testing
Istqb ctfl-series - Black Box Testing
 
Amin Milani Fard: Directed Model Inference for Testing and Analysis of Web Ap...
Amin Milani Fard: Directed Model Inference for Testing and Analysis of Web Ap...Amin Milani Fard: Directed Model Inference for Testing and Analysis of Web Ap...
Amin Milani Fard: Directed Model Inference for Testing and Analysis of Web Ap...
 
Software Testing Techniques
Software Testing TechniquesSoftware Testing Techniques
Software Testing Techniques
 
Advances in Unit Testing: Theory and Practice
Advances in Unit Testing: Theory and PracticeAdvances in Unit Testing: Theory and Practice
Advances in Unit Testing: Theory and Practice
 

Viewers also liked

Property-based testing
Property-based testingProperty-based testing
Property-based testingPeter Gromov
 
ScalaCheckでProperty-based Testing
ScalaCheckでProperty-based TestingScalaCheckでProperty-based Testing
ScalaCheckでProperty-based TestingKoji Agawa
 
Property-Based Testing for Services
Property-Based Testing for ServicesProperty-Based Testing for Services
Property-Based Testing for Servicesjessitron
 
Property based testing - Less is more
Property based testing - Less is moreProperty based testing - Less is more
Property based testing - Less is moreHo Tien VU
 
Better Tests, Less Code: Property-based Testing
Better Tests, Less Code: Property-based TestingBetter Tests, Less Code: Property-based Testing
Better Tests, Less Code: Property-based TestingC4Media
 
Property based Testing - generative data & executable domain rules
Property based Testing - generative data & executable domain rulesProperty based Testing - generative data & executable domain rules
Property based Testing - generative data & executable domain rulesDebasish Ghosh
 
An introduction to property based testing
An introduction to property based testingAn introduction to property based testing
An introduction to property based testingScott Wlaschin
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPTsuhasreddy1
 

Viewers also liked (11)

Pino coviello, rodriguez
Pino coviello, rodriguezPino coviello, rodriguez
Pino coviello, rodriguez
 
Property Based Testing
Property Based TestingProperty Based Testing
Property Based Testing
 
Property-based testing
Property-based testingProperty-based testing
Property-based testing
 
Property-based testing
Property-based testingProperty-based testing
Property-based testing
 
ScalaCheckでProperty-based Testing
ScalaCheckでProperty-based TestingScalaCheckでProperty-based Testing
ScalaCheckでProperty-based Testing
 
Property-Based Testing for Services
Property-Based Testing for ServicesProperty-Based Testing for Services
Property-Based Testing for Services
 
Property based testing - Less is more
Property based testing - Less is moreProperty based testing - Less is more
Property based testing - Less is more
 
Better Tests, Less Code: Property-based Testing
Better Tests, Less Code: Property-based TestingBetter Tests, Less Code: Property-based Testing
Better Tests, Less Code: Property-based Testing
 
Property based Testing - generative data & executable domain rules
Property based Testing - generative data & executable domain rulesProperty based Testing - generative data & executable domain rules
Property based Testing - generative data & executable domain rules
 
An introduction to property based testing
An introduction to property based testingAn introduction to property based testing
An introduction to property based testing
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPT
 

Similar to Making property-based testing easier to read for humans

Chapter 10 Testing and Quality Assurance1Unders.docx
Chapter 10 Testing and Quality Assurance1Unders.docxChapter 10 Testing and Quality Assurance1Unders.docx
Chapter 10 Testing and Quality Assurance1Unders.docxketurahhazelhurst
 
Automation Testing theory notes.pptx
Automation Testing theory notes.pptxAutomation Testing theory notes.pptx
Automation Testing theory notes.pptxNileshBorkar12
 
Anders Claesson - Test Strategies in Agile Projects - EuroSTAR 2010
Anders Claesson - Test Strategies in Agile Projects - EuroSTAR 2010Anders Claesson - Test Strategies in Agile Projects - EuroSTAR 2010
Anders Claesson - Test Strategies in Agile Projects - EuroSTAR 2010TEST Huddle
 
Test Driven Development - The art of fearless programming
Test Driven Development - The art of fearless programmingTest Driven Development - The art of fearless programming
Test Driven Development - The art of fearless programmingChamil Jeewantha
 
Role+Of+Testing+In+Sdlc
Role+Of+Testing+In+SdlcRole+Of+Testing+In+Sdlc
Role+Of+Testing+In+Sdlcmahendra singh
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTscatherinewall
 
B2 2005 introduction_load_testing_blackboard_primer_draft
B2 2005 introduction_load_testing_blackboard_primer_draftB2 2005 introduction_load_testing_blackboard_primer_draft
B2 2005 introduction_load_testing_blackboard_primer_draftSteve Feldman
 
Introduction to programming with python
Introduction to programming with pythonIntroduction to programming with python
Introduction to programming with pythonPorimol Chandro
 
Xp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And MocksXp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And Mocksguillaumecarre
 
Software development effort reduction with Co-op
Software development effort reduction with Co-opSoftware development effort reduction with Co-op
Software development effort reduction with Co-oplbergmans
 
Use Case Workshop
Use Case WorkshopUse Case Workshop
Use Case Workshopelkensteyin
 
OORPT Dynamic Analysis
OORPT Dynamic AnalysisOORPT Dynamic Analysis
OORPT Dynamic Analysislienhard
 
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...ESEM 2014
 
Cs6502 ooad-cse-vst-au-unit-v dce
Cs6502 ooad-cse-vst-au-unit-v dceCs6502 ooad-cse-vst-au-unit-v dce
Cs6502 ooad-cse-vst-au-unit-v dcetagoreengineering
 
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web Testing
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web TestingThe Automation Firehose: Be Strategic & Tactical With Your Mobile & Web Testing
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web TestingPerfecto by Perforce
 

Similar to Making property-based testing easier to read for humans (20)

Chapter 10 Testing and Quality Assurance1Unders.docx
Chapter 10 Testing and Quality Assurance1Unders.docxChapter 10 Testing and Quality Assurance1Unders.docx
Chapter 10 Testing and Quality Assurance1Unders.docx
 
Automation Testing theory notes.pptx
Automation Testing theory notes.pptxAutomation Testing theory notes.pptx
Automation Testing theory notes.pptx
 
Anders Claesson - Test Strategies in Agile Projects - EuroSTAR 2010
Anders Claesson - Test Strategies in Agile Projects - EuroSTAR 2010Anders Claesson - Test Strategies in Agile Projects - EuroSTAR 2010
Anders Claesson - Test Strategies in Agile Projects - EuroSTAR 2010
 
Test Driven Development - The art of fearless programming
Test Driven Development - The art of fearless programmingTest Driven Development - The art of fearless programming
Test Driven Development - The art of fearless programming
 
Effective unit testing
Effective unit testingEffective unit testing
Effective unit testing
 
Role+Of+Testing+In+Sdlc
Role+Of+Testing+In+SdlcRole+Of+Testing+In+Sdlc
Role+Of+Testing+In+Sdlc
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
Siguccs20101026
Siguccs20101026Siguccs20101026
Siguccs20101026
 
B2 2005 introduction_load_testing_blackboard_primer_draft
B2 2005 introduction_load_testing_blackboard_primer_draftB2 2005 introduction_load_testing_blackboard_primer_draft
B2 2005 introduction_load_testing_blackboard_primer_draft
 
Introduction to programming with python
Introduction to programming with pythonIntroduction to programming with python
Introduction to programming with python
 
Xp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And MocksXp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And Mocks
 
XP through TDD
XP through TDDXP through TDD
XP through TDD
 
Software development effort reduction with Co-op
Software development effort reduction with Co-opSoftware development effort reduction with Co-op
Software development effort reduction with Co-op
 
Use Case Workshop
Use Case WorkshopUse Case Workshop
Use Case Workshop
 
OORPT Dynamic Analysis
OORPT Dynamic AnalysisOORPT Dynamic Analysis
OORPT Dynamic Analysis
 
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
 
Sdlc
SdlcSdlc
Sdlc
 
Sdlc
SdlcSdlc
Sdlc
 
Cs6502 ooad-cse-vst-au-unit-v dce
Cs6502 ooad-cse-vst-au-unit-v dceCs6502 ooad-cse-vst-au-unit-v dce
Cs6502 ooad-cse-vst-au-unit-v dce
 
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web Testing
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web TestingThe Automation Firehose: Be Strategic & Tactical With Your Mobile & Web Testing
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web Testing
 

More from Laura M. Castro

Ola, ChatGPT... que carreira sería boa para min?
Ola, ChatGPT... que carreira sería boa para min?Ola, ChatGPT... que carreira sería boa para min?
Ola, ChatGPT... que carreira sería boa para min?Laura M. Castro
 
IAs xerativas e nesgos de xénero
IAs xerativas e nesgos de xéneroIAs xerativas e nesgos de xénero
IAs xerativas e nesgos de xéneroLaura M. Castro
 
As intelixencias artificiais como xeradoras de cultura: exploración dos nesgo...
As intelixencias artificiais como xeradoras de cultura: exploración dos nesgo...As intelixencias artificiais como xeradoras de cultura: exploración dos nesgo...
As intelixencias artificiais como xeradoras de cultura: exploración dos nesgo...Laura M. Castro
 
David vs. Goliat: lecciones aprendidas de una experiencia fallida de adopción...
David vs. Goliat: lecciones aprendidas de una experiencia fallida de adopción...David vs. Goliat: lecciones aprendidas de una experiencia fallida de adopción...
David vs. Goliat: lecciones aprendidas de una experiencia fallida de adopción...Laura M. Castro
 
Why on Earth would I test if I have to just "Let it crash"?
Why on Earth would I test if I have to just "Let it crash"?Why on Earth would I test if I have to just "Let it crash"?
Why on Earth would I test if I have to just "Let it crash"?Laura M. Castro
 
How the BEAM will change your mind
How the BEAM will change your mindHow the BEAM will change your mind
How the BEAM will change your mindLaura M. Castro
 
So I used Erlang... is my system as scalable as they say it'd be?
So I used Erlang... is my system as scalable as they say it'd be?So I used Erlang... is my system as scalable as they say it'd be?
So I used Erlang... is my system as scalable as they say it'd be?Laura M. Castro
 
Elixir: the not-so-hidden path to Erlang
Elixir: the not-so-hidden path to ErlangElixir: the not-so-hidden path to Erlang
Elixir: the not-so-hidden path to ErlangLaura M. Castro
 
Automatic generation of UML sequence diagrams from test counterexamples
Automatic generation of UML sequence diagrams from test counterexamplesAutomatic generation of UML sequence diagrams from test counterexamples
Automatic generation of UML sequence diagrams from test counterexamplesLaura M. Castro
 
Erlang as a supporting technology for teaching Software Architecture
Erlang as a supporting technology for teaching Software ArchitectureErlang as a supporting technology for teaching Software Architecture
Erlang as a supporting technology for teaching Software ArchitectureLaura M. Castro
 
A Backpack to go the Extra-Functional Mile (a hitched hike by the PROWESS pro...
A Backpack to go the Extra-Functional Mile (a hitched hike by the PROWESS pro...A Backpack to go the Extra-Functional Mile (a hitched hike by the PROWESS pro...
A Backpack to go the Extra-Functional Mile (a hitched hike by the PROWESS pro...Laura M. Castro
 
Experiencias Industriales con Programación Declarativa
Experiencias Industriales con Programación DeclarativaExperiencias Industriales con Programación Declarativa
Experiencias Industriales con Programación DeclarativaLaura M. Castro
 
Functional programming goes to Hollywood... and around the world!
Functional programming goes to Hollywood... and around the world!Functional programming goes to Hollywood... and around the world!
Functional programming goes to Hollywood... and around the world!Laura M. Castro
 
Failover and takeover contingency mechanisms for network partition and node f...
Failover and takeover contingency mechanisms for network partition and node f...Failover and takeover contingency mechanisms for network partition and node f...
Failover and takeover contingency mechanisms for network partition and node f...Laura M. Castro
 
Editing documents with LaTeX
Editing documents with LaTeXEditing documents with LaTeX
Editing documents with LaTeXLaura M. Castro
 
Introdución á edición de textos con LaTeX
Introdución á edición de textos con LaTeXIntrodución á edición de textos con LaTeX
Introdución á edición de textos con LaTeXLaura M. Castro
 
Edición de textos con LaTeX
Edición de textos con LaTeXEdición de textos con LaTeX
Edición de textos con LaTeXLaura M. Castro
 
Edición de textos con LaTeX
Edición de textos con LaTeXEdición de textos con LaTeX
Edición de textos con LaTeXLaura M. Castro
 
Improving software development using Erlang/OTP
Improving software development using Erlang/OTPImproving software development using Erlang/OTP
Improving software development using Erlang/OTPLaura M. Castro
 

More from Laura M. Castro (20)

Ola, ChatGPT... que carreira sería boa para min?
Ola, ChatGPT... que carreira sería boa para min?Ola, ChatGPT... que carreira sería boa para min?
Ola, ChatGPT... que carreira sería boa para min?
 
IAs xerativas e nesgos de xénero
IAs xerativas e nesgos de xéneroIAs xerativas e nesgos de xénero
IAs xerativas e nesgos de xénero
 
As intelixencias artificiais como xeradoras de cultura: exploración dos nesgo...
As intelixencias artificiais como xeradoras de cultura: exploración dos nesgo...As intelixencias artificiais como xeradoras de cultura: exploración dos nesgo...
As intelixencias artificiais como xeradoras de cultura: exploración dos nesgo...
 
David vs. Goliat: lecciones aprendidas de una experiencia fallida de adopción...
David vs. Goliat: lecciones aprendidas de una experiencia fallida de adopción...David vs. Goliat: lecciones aprendidas de una experiencia fallida de adopción...
David vs. Goliat: lecciones aprendidas de una experiencia fallida de adopción...
 
Why on Earth would I test if I have to just "Let it crash"?
Why on Earth would I test if I have to just "Let it crash"?Why on Earth would I test if I have to just "Let it crash"?
Why on Earth would I test if I have to just "Let it crash"?
 
How the BEAM will change your mind
How the BEAM will change your mindHow the BEAM will change your mind
How the BEAM will change your mind
 
Elixir vs Java
Elixir vs JavaElixir vs Java
Elixir vs Java
 
So I used Erlang... is my system as scalable as they say it'd be?
So I used Erlang... is my system as scalable as they say it'd be?So I used Erlang... is my system as scalable as they say it'd be?
So I used Erlang... is my system as scalable as they say it'd be?
 
Elixir: the not-so-hidden path to Erlang
Elixir: the not-so-hidden path to ErlangElixir: the not-so-hidden path to Erlang
Elixir: the not-so-hidden path to Erlang
 
Automatic generation of UML sequence diagrams from test counterexamples
Automatic generation of UML sequence diagrams from test counterexamplesAutomatic generation of UML sequence diagrams from test counterexamples
Automatic generation of UML sequence diagrams from test counterexamples
 
Erlang as a supporting technology for teaching Software Architecture
Erlang as a supporting technology for teaching Software ArchitectureErlang as a supporting technology for teaching Software Architecture
Erlang as a supporting technology for teaching Software Architecture
 
A Backpack to go the Extra-Functional Mile (a hitched hike by the PROWESS pro...
A Backpack to go the Extra-Functional Mile (a hitched hike by the PROWESS pro...A Backpack to go the Extra-Functional Mile (a hitched hike by the PROWESS pro...
A Backpack to go the Extra-Functional Mile (a hitched hike by the PROWESS pro...
 
Experiencias Industriales con Programación Declarativa
Experiencias Industriales con Programación DeclarativaExperiencias Industriales con Programación Declarativa
Experiencias Industriales con Programación Declarativa
 
Functional programming goes to Hollywood... and around the world!
Functional programming goes to Hollywood... and around the world!Functional programming goes to Hollywood... and around the world!
Functional programming goes to Hollywood... and around the world!
 
Failover and takeover contingency mechanisms for network partition and node f...
Failover and takeover contingency mechanisms for network partition and node f...Failover and takeover contingency mechanisms for network partition and node f...
Failover and takeover contingency mechanisms for network partition and node f...
 
Editing documents with LaTeX
Editing documents with LaTeXEditing documents with LaTeX
Editing documents with LaTeX
 
Introdución á edición de textos con LaTeX
Introdución á edición de textos con LaTeXIntrodución á edición de textos con LaTeX
Introdución á edición de textos con LaTeX
 
Edición de textos con LaTeX
Edición de textos con LaTeXEdición de textos con LaTeX
Edición de textos con LaTeX
 
Edición de textos con LaTeX
Edición de textos con LaTeXEdición de textos con LaTeX
Edición de textos con LaTeX
 
Improving software development using Erlang/OTP
Improving software development using Erlang/OTPImproving software development using Erlang/OTP
Improving software development using Erlang/OTP
 

Recently uploaded

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Recently uploaded (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

Making property-based testing easier to read for humans

  • 1. Making property-based testing easier to read for humans Laura M. Castro February 18th, 2016
  • 2. Stakeholder involvement & software testing The challenge of communication Active stakeholder participation is an agile best practice1 Early testing is also an agile best practice1 1 Agile practices are considered mainstream, with adoption rates ≈50%2 of 30
  • 3. Stakeholder involvement & software testing The challenge of communication Active stakeholder participation is an agile best practice1 stakeholder involvement requires inclusive modeling (UML activity diagrams, user stories) Early testing is also an agile best practice1 best represented by Test-Driven Development (TDD) 1 Agile practices are considered mainstream, with adoption rates ≈50%2 of 30
  • 4. Stakeholder involvement & software testing The challenge of communication Active stakeholder participation is an agile best practice1 stakeholder involvement requires inclusive modeling (UML activity diagrams, user stories) Early testing is also an agile best practice1 best represented by Test-Driven Development (TDD) stakeholder involvement + early testing = Behaviour-Driven Development (BDD) 1 Agile practices are considered mainstream, with adoption rates ≈50%2 of 30
  • 5. Behaviour-Driven Development Feature: Deletion of element from list In order to operate lists As a user of the lists module I want to delete an element from a list Scenario: Delete integer from list of integers Given I have the integer 3 And I have the list of integers [0,8,6] When I use the function lists:delete/2 Then the resulting list should not contain 3 3 of 30
  • 6. Behaviour-Driven Development The behaviour becomes test case given("I have the integer (d+)", S, [Num]) -> {ok, S ++ [list_to_integer(Num)]}; ... when("I use the function (w+) from the module (w+)", S, [F, M]) -> {ok, apply(list_to_atom(M), list_to_atom(F), S)}. then("the resulting list should not contain (d+)", S, [Num]) -> case not lists:member(list_to_integer(Num), S) of true -> {ok, S}; false -> {failed, S} end. 4 of 30
  • 9. Behaviour-Driven Development Pros and cons Good as communication tool a number of implementations in many languages: C++, Clojure, Erlang, Java, JavaScript, Lua, .NET, PHP,… Not as good as testing tool run as many test cases as you can write well-known problems of “traditional” testing: specification, implementation, maintainability, effectiveness 7 of 30
  • 10. Property-Based Testing (PBT) Strategy for improved testing: abstraction + automation write properties instead of test cases properties are used to automatically generate, run, and diagnose many, many test cases 8 of 30
  • 11. Property-Based Testing A very simple example How do you write properties? Let’s start simple: Example: delete an element from a list 9 of 30
  • 12. Property-Based Testing A very simple example How do you write properties? Let’s start simple: Example: delete an element from a list Desired functionality? If I delete an element from a list, it shouldn't be there anymore. 9 of 30
  • 13. Property-Based Testing A very simple example How do you write properties? Let’s start simple: Example: delete an element from a list Desired functionality? If I delete an element from a list, it shouldn't be there anymore. Which item? Which list? Any. 9 of 30
  • 14. Property-Based Testing A very simple example prop_simple() -> ?FORALL(I, item(), ?FORALL(L, list(item()), not lists:member(I, lists:delete(I, L)))). 10 of 30
  • 15. Property-Based Testing A very simple example prop_simple() -> ?FORALL(I, item(), ?FORALL(L, list(item()), not lists:member(I, lists:delete(I, L)))). 11 of 30
  • 16. Property-Based Testing A very simple example prop_simple() -> ?FORALL(I, item(), ?FORALL(L, list(item()), not lists:member(I, lists:delete(I, L)))). 12 of 30
  • 17. Property-Based Testing A very simple example prop_simple() -> ?FORALL(I, item(), ?FORALL(L, list(item()), [] == [ X || X <- lists:delete(I, L), X == I])). 13 of 30
  • 18. Property-Based Testing A very simple example prop_simple() -> ?FORALL(I, item(), ?FORALL(L, list(item()), not lists:member(I, lists:delete(I, L)))). 14 of 30
  • 19. Property-Based Testing A very simple example > eqc:quickcheck(simple_eqc:prop_simple()). ................................................ ................................................ .... OK, passed 100 tests 15 of 30
  • 20. Property-Based Testing A very simple example > eqc:quickcheck(simple_eqc:prop_simple()). ................................................ .................... Failed! After 69 tests. 15 [-13,-15,-2,-17,-20,15,15] Shrinking xxxxxxxx.xx.xxxxxxxx (2 times) 15 [15,15] 16 of 30
  • 21. Property-Based Testing A more complex example How complex can it get? Models for stateful components. Example: EVM registry register(Name, Pid) -> ok unregister(Name) -> ok whereis(Name) -> Pid | undefined 17 of 30
  • 22. Property-Based Testing A more complex example How complex can it get? Models for stateful components. Example: EVM registry register(Name, Pid) -> ok unregister(Name) -> ok whereis(Name) -> Pid | undefined Desired functionality? If I perform a sequence of registry actions, I expect compliance with model at all times. 17 of 30
  • 23. Property-Based Testing A more complex example How complex can it get? Models for stateful components. Example: EVM registry register(Name, Pid) -> ok unregister(Name) -> ok whereis(Name) -> Pid | undefined Desired functionality? If I perform a sequence of registry actions, I expect compliance with model at all times. Which sequences of actions? Any. 17 of 30
  • 24. Property-Based Testing A more complex example prop_registry() -> ?FORALL(Cmds, commands(registry_model), begin ... % setup code {H, S, TResult} = run_commands(registry_model,Cmds), ... % cleanup code TResult == ok end). 18 of 30
  • 25. Property-Based Testing A more complex example prop_registry() -> ?FORALL(Cmds, commands(registry_model), begin ... % setup code {H, S, TResult} = run_commands(registry_model,Cmds), ... % cleanup code TResult == ok end). 19 of 30
  • 26. Property-Based Testing A more complex example register_pre(S) -> S#state.pids /= []. ... unregister_next(S,_,[Name]) -> S#state{regs = lists:keydelete(Name,1,S#state.regs)}. ... whereis_post(S, [Name], Result) -> case lists:keyfind(Name, 1, S#state.regs) of {Name,Value} -> Res =:= Value; false -> Res =:= undefined end. 20 of 30
  • 27. Property-Based Testing Pros and cons Good as testing tool run as many test cases as you have time to execute run different test cases every time get reduced counterexamples, for focused debugging get a functional specification of the software a number of implementations in many languages: Clojure, Lisp, Erlang, ML, Prolog, Scala, Scheme, Smalltalk,… Not as good as communication tool 21 of 30
  • 28. readSpec making PBT easier to read for humans Get (semi)natural language descriptions for sample test cases that test properties produce 1. Write PBT artifacts (properties, models) 2. Get readSpec to translate them into cucumber-like features implemented in Erlang uses Quviq QuickCheck’s coverage-based suite generation Available at: https://github.com/prowessproject/readspec 22 of 30
  • 29. readSpec A very simple example: what do you get? File: simple.feature FEATURE: simple Simple QuickCheck properties ... SCENARIO: Deleting an integer from a list should result in a list that does not contain that integer. GIVEN I have the integer 6 AND I have the list [-1, 2, 13, 0, 5] THEN IS FALSE THAT the integer 6 is in the result of calling lists:delete/2 with 6 and [-1, 2, 13, 0, 5]. ... 23 of 30
  • 30. readSpec A very simple example: what do you get? File: prop_simple.counterexample.feature GIVEN I have the integer 15 AND I have the list [15, 15] THEN the integer 15 is in the result of calling lists:delete/2 with 15 and [15, 15]. 24 of 30
  • 31. readSpec A very simple example: what do you get? ********************************************************** CALL: register/2 ********************************************************** POSSIBILITIES ... ================================ *** REQUIREMENTS *** [*] The field called "pids" must be equal to the empty list *** RESULT *** the literal 'false' ================================ OTHERWISE ... ================================ *** RESULT *** the literal 'true' 25 of 30
  • 32. VoDKATV: industrial pilot study 26 of 30
  • 33. VoDKATV: industrial pilot study Research questions RQ 1) Can readSpec produce efficient text representations of test properties? RQ 2) Are readSpec text representations an effective way to communicate among stakeholders? 27 of 30
  • 34. VoDKATV: industrial pilot study Measurements RQ 1) Amount of time to generate the textual representation RQ 1) LOC of textual representations w.r.t. LOC of corresponding test properties/models RQ 2) Stakeholders average rating of usefulness (would use them instead of current way of communic.?) RQ 2) Stakeholders average rating of usability (appropriate? easy to understand/follow?) 28 of 30
  • 35. VoDKATV: industrial pilot study Results Amount of time needed in the order of milliseconds Nature of output (verbosity, number of lines) appropriate Simple cases: high degree of influence of personal skills and background on deeming text more helpful than property code Complex cases: some people still cannot make sense of either; the rest consistently agree the text is more helpful enough to provide the insights needed to suggest more tests! 29 of 30
  • 36. readSpec: making PBT easier to read for humans Final quotes “readSpec looks human-friendly” “simple cases are too verbose for tech people (code is shorter)” “helps in understanding tests better, especially when they’re complex” “it’s interesting when cases reach certain complexity” “presents requirements in an explicit way, that can slip your mind o/w” “this is very helpful for people who are not familiar with the code” “only with a good level of maturity and experience one could be more comfortable with QC properties and models” 30 of 30