SlideShare una empresa de Scribd logo
1 de 23
Descargar para leer sin conexión
Expressive Testing
…and your Code For Free?
Tim Mackinnon
www.iterex.co.uk
Presentation Outline+Objectives
SUnit – features and flaws
Importance Of Failures – failing is good right?
Readability
Assertions as Intent
More specific testing
Code for free
I want to get feedback on these ideas, is there
something interesting?
SUnit – 13 Years On
From the SUnit site:
“SUnit is the mother of all unit testing frameworks, and
serves as one of the cornerstones of test-driven
development methodologies such as eXtreme
Programming”
Simple model for testing, inspired many X-Unit clones
Available on all Smalltalk implementations
Current Smalltalk version is 3.1 – stable but no recent
development work
Many popular frameworks ship with SUnit tests. So how
are tests in the wild?
Sample SUnit test
Sample SUnit Result
Very minimal indication of
the cause of the failure
Sample SUnit Result
Slightly improved failure indication in the status bar
via “Intelli-Dolphin” but still not particularly helpful
So what’s wrong with this?
Generic style tests require using a debugger to find out
the problem
The error displayed the in SUnit Runner is not very
descriptive/helpful
Not bad when doing initial TDD, but if mass failures afterwards,
can be tedious to track down a problem
Not always clear that you got the failure you expected unless
you take the time to debug
Erwin Reichstein (Carleton University – undergrad CS)
“If you don’t find any errors in your code – you should be
very worried”
How about writing tests a different way?
Concisely indicate your test intent, and leverage this information to
give clear messages for inevitable failure…
And presenting test results more usefully?
Constraint provides a much clearer indication of the error
SUnit Issues that cropped up…
TestResults do not store the exception that causes them
Therefore a UI has no additional information to report
If you store the exception, how can you get a meaningful
message from it?
Expressing Expectations as Objects
Create a family of Constraint
objects with a protocol:
#satisfies:
#verifyWith:
#errorMessageFor:
#printAbbreviationOn:
Try to use readable
terminology for instantiation
Equal to:
Less than:
Loose methods for
convenience of instantiation
#shouldEqual:
Lets explore some code
More Complex Constraints
constraint :=
(Begins with: 'p') | (Ends with: ‘s') & [:i | i size < 5].
In using constraints, discovered some useful new
patterns:
(Begins with: 'p') & Different values.
Only values: #(‘peter’ ‘john’)
Sequence of: #(‘peter’ ‘john’ ‘harry’)
Leverage these objects to generate more specific error
messages:
“john not item 1 in #(‘peter’ ‘john’ ‘harry’)
Do constraints have other users?
Yes - Specifying expected values on method calls for
testing:
MethodWrappers
MockObjects
Code generation
Example of a test using Mocks and Constraints
ObjectDocumentor
SUnitTest Reporter
SUnitNameParser
Use Constraints ( ) to verify each invocation
to a proxy object
Example Mock test using constraints
testDoesntProcessNonTestMethods
|report nameParser methods documentor|
methods := #('setUp' 'testCalculates').
nameParser := mockery createMock: #SUnitNameParser.
report := mockery createMock: #ResponsibilityReport.
documentor := ObjectDocumentor new.
[documentor process: methods using: nameParser onto: report]
expecting:
([nameParser isTestMethod: (Only values: methods)]
answerWith: #(false true))
+ ([nameParser parse: 'testCalculates']
answer: 'Calculates' exactly: 1)
+ [report printResponsibility:
(Kind of: String) &~ (Begins with: 'test')] once
Generating Code from tests….
Run the tests, gather all the mock objects used, ask
them to generate code, protocols, comments.
Future Work
Keep gathering useful constraints (like Sequence,
Different etc.)
Investigate if constraints can improve code generation
(beyond simplistic usages)
Investigate whether constraints can infer missing or
conflicting test cases
Conclusions
Summary
When a test fails – ask yourself:
Is it telling me everything it can about the failure?
Would expressing it as a test constraint make it
clearer?
Speaker:
Tim Mackinnon
http://www.iterex.co.uk/research
Related Work
James Robertson’s Daily Smalltalk: ComplexConditions
(http://www.cincomsmalltalk.com/casts/stDaily/2007/smalltalk_da
ily-08-15-07.html)
Acknowledgements
Blaine Buxton/Brian Rice for encouragement at
STS2006
Nat Pryce for introducing me to the idea of constraints as
objects
Tim Mackinnon - Who are you?
1996 – OTI
Developer on teams credited for early use of agile practices
1999 – Connextra
Formed one of the first Agile teams in the UK
Invented “Mock Objects” test technique
Pioneered Iteration/Heartbeat Retrospectives
2003 – ThoughtWorks
Agile enablement coaching
Established hi-level release estimation techniques
Developed worldwide QuickStart project workshops
2006 – Iterative Excellence
Tailored Consulting for Agile projects
Iterex Professional – Software helping teams plan and track agile
projects

Más contenido relacionado

La actualidad más candente

The Art Of Debugging
The Art Of DebuggingThe Art Of Debugging
The Art Of Debugging
svilen.ivanov
 
Test design techniques
Test design techniquesTest design techniques
Test design techniques
Oksana
 
Test case design_the_basicsv0.4
Test case design_the_basicsv0.4Test case design_the_basicsv0.4
Test case design_the_basicsv0.4
guest31fced
 
Sqa, test scenarios and test cases
Sqa, test scenarios and test casesSqa, test scenarios and test cases
Sqa, test scenarios and test cases
Confiz
 
Test Cases Maintaining & Documenting
Test Cases Maintaining & DocumentingTest Cases Maintaining & Documenting
Test Cases Maintaining & Documenting
Seyed Ali Marjaie
 
Best Practices for Test Case Writing
Best Practices for Test Case WritingBest Practices for Test Case Writing
Best Practices for Test Case Writing
Sarah Goldberg
 
Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6
helpido9
 
Advanced unit testing – real life examples and mistakes
Advanced unit testing – real life examples and mistakesAdvanced unit testing – real life examples and mistakes
Advanced unit testing – real life examples and mistakes
Milan Vukoje
 

La actualidad más candente (19)

The Art Of Debugging
The Art Of DebuggingThe Art Of Debugging
The Art Of Debugging
 
Test design techniques
Test design techniquesTest design techniques
Test design techniques
 
Debugging by induction
Debugging by inductionDebugging by induction
Debugging by induction
 
Test case design_the_basicsv0.4
Test case design_the_basicsv0.4Test case design_the_basicsv0.4
Test case design_the_basicsv0.4
 
Sqa, test scenarios and test cases
Sqa, test scenarios and test casesSqa, test scenarios and test cases
Sqa, test scenarios and test cases
 
Bt0082, visual basic
Bt0082, visual basicBt0082, visual basic
Bt0082, visual basic
 
Test Cases Maintaining & Documenting
Test Cases Maintaining & DocumentingTest Cases Maintaining & Documenting
Test Cases Maintaining & Documenting
 
Industrial Control System Assignment Help|25% Online Assignment Help
Industrial Control System Assignment Help|25% Online Assignment HelpIndustrial Control System Assignment Help|25% Online Assignment Help
Industrial Control System Assignment Help|25% Online Assignment Help
 
Best Practices for Test Case Writing
Best Practices for Test Case WritingBest Practices for Test Case Writing
Best Practices for Test Case Writing
 
Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6
 
Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6Cis 355 i lab 1 of 6
Cis 355 i lab 1 of 6
 
Blackbox
BlackboxBlackbox
Blackbox
 
Programming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStringsProgramming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStrings
 
Dakiry_qastandup_Olia Didyk_testdesign
Dakiry_qastandup_Olia Didyk_testdesignDakiry_qastandup_Olia Didyk_testdesign
Dakiry_qastandup_Olia Didyk_testdesign
 
Md university cmis 102 week 5 hands
Md university cmis 102 week 5 handsMd university cmis 102 week 5 hands
Md university cmis 102 week 5 hands
 
Test design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniquesTest design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniques
 
Advanced unit testing – real life examples and mistakes
Advanced unit testing – real life examples and mistakesAdvanced unit testing – real life examples and mistakes
Advanced unit testing – real life examples and mistakes
 
Test design techniques
Test design techniquesTest design techniques
Test design techniques
 
Software Debugging for High-altitude Balloons
Software Debugging for High-altitude BalloonsSoftware Debugging for High-altitude Balloons
Software Debugging for High-altitude Balloons
 

Destacado

Dachbegruener 1 2009
Dachbegruener 1 2009Dachbegruener 1 2009
Dachbegruener 1 2009
guest6d9a536
 
Presentación1
Presentación1Presentación1
Presentación1
crisept08
 
Ads Sesion1 10393
Ads Sesion1 10393Ads Sesion1 10393
Ads Sesion1 10393
guest31882d
 
PresentacióN Sobre Software Libre En EducacióN De Maria Polo Ribera
PresentacióN Sobre Software Libre En EducacióN De Maria Polo RiberaPresentacióN Sobre Software Libre En EducacióN De Maria Polo Ribera
PresentacióN Sobre Software Libre En EducacióN De Maria Polo Ribera
guest445331
 
Me echaron de ingenieria
Me echaron de ingenieriaMe echaron de ingenieria
Me echaron de ingenieria
AxelMR
 

Destacado (20)

Cincom Smalltalk
Cincom SmalltalkCincom Smalltalk
Cincom Smalltalk
 
Jesucristo
JesucristoJesucristo
Jesucristo
 
Dachbegruener 1 2009
Dachbegruener 1 2009Dachbegruener 1 2009
Dachbegruener 1 2009
 
Presentación1
Presentación1Presentación1
Presentación1
 
Power point pa
Power point paPower point pa
Power point pa
 
Cassoela
CassoelaCassoela
Cassoela
 
Ostern 1 b
Ostern 1 bOstern 1 b
Ostern 1 b
 
Livro
LivroLivro
Livro
 
Ads Sesion1 10393
Ads Sesion1 10393Ads Sesion1 10393
Ads Sesion1 10393
 
Weihnachten in binago
Weihnachten in binagoWeihnachten in binago
Weihnachten in binago
 
00gt0411 (1)
00gt0411 (1)00gt0411 (1)
00gt0411 (1)
 
PresentacióN Sobre Software Libre En EducacióN De Maria Polo Ribera
PresentacióN Sobre Software Libre En EducacióN De Maria Polo RiberaPresentacióN Sobre Software Libre En EducacióN De Maria Polo Ribera
PresentacióN Sobre Software Libre En EducacióN De Maria Polo Ribera
 
DGT Multimodal - Apresentação Institucional
DGT Multimodal - Apresentação InstitucionalDGT Multimodal - Apresentação Institucional
DGT Multimodal - Apresentação Institucional
 
Vision 2020
Vision 2020Vision 2020
Vision 2020
 
Software para Imobiliaria
Software para ImobiliariaSoftware para Imobiliaria
Software para Imobiliaria
 
Test con truco
Test con trucoTest con truco
Test con truco
 
Percepcion
PercepcionPercepcion
Percepcion
 
Historia De Amor
Historia De Amor Historia De Amor
Historia De Amor
 
Me echaron de ingenieria
Me echaron de ingenieriaMe echaron de ingenieria
Me echaron de ingenieria
 
Sociedade informação
Sociedade informaçãoSociedade informação
Sociedade informação
 

Similar a Expressive Testing ...and your Code For Free?

Computer Software Testing Basics introduced.ppt
Computer Software Testing Basics introduced.pptComputer Software Testing Basics introduced.ppt
Computer Software Testing Basics introduced.ppt
TrevorChinguwo
 
Unit testing (workshop)
Unit testing (workshop)Unit testing (workshop)
Unit testing (workshop)
Foyzul Karim
 

Similar a Expressive Testing ...and your Code For Free? (20)

Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Unit testing
Unit testingUnit testing
Unit testing
 
utPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQLutPLSQL: Unit Testing for Oracle PL/SQL
utPLSQL: Unit Testing for Oracle PL/SQL
 
SELJE_Database_Unit_Testing_Slides.pdf
SELJE_Database_Unit_Testing_Slides.pdfSELJE_Database_Unit_Testing_Slides.pdf
SELJE_Database_Unit_Testing_Slides.pdf
 
How to complement TDD with static analysis
How to complement TDD with static analysisHow to complement TDD with static analysis
How to complement TDD with static analysis
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in Java
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + Eclipse
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
 
Unit test
Unit testUnit test
Unit test
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
SE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitSE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and Junit
 
Computer Software Testing Basics introduced.ppt
Computer Software Testing Basics introduced.pptComputer Software Testing Basics introduced.ppt
Computer Software Testing Basics introduced.ppt
 
Unit testing (workshop)
Unit testing (workshop)Unit testing (workshop)
Unit testing (workshop)
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Nguyenvandungb seminar
Nguyenvandungb seminarNguyenvandungb seminar
Nguyenvandungb seminar
 
Soren Lynggaard & Pusser Janvit - How To Hire A True Tester - EuroSTAR 2013
Soren Lynggaard & Pusser Janvit - How To Hire A True Tester - EuroSTAR 2013Soren Lynggaard & Pusser Janvit - How To Hire A True Tester - EuroSTAR 2013
Soren Lynggaard & Pusser Janvit - How To Hire A True Tester - EuroSTAR 2013
 

Más de ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
ESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
ESUG
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
ESUG
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
ESUG
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
ESUG
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
ESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
ESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
ESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
ESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
ESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
ESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
ESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
ESUG
 

Más de ESUG (20)

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

Expressive Testing ...and your Code For Free?

  • 1. Expressive Testing …and your Code For Free? Tim Mackinnon www.iterex.co.uk
  • 2. Presentation Outline+Objectives SUnit – features and flaws Importance Of Failures – failing is good right? Readability Assertions as Intent More specific testing Code for free I want to get feedback on these ideas, is there something interesting?
  • 3. SUnit – 13 Years On From the SUnit site: “SUnit is the mother of all unit testing frameworks, and serves as one of the cornerstones of test-driven development methodologies such as eXtreme Programming” Simple model for testing, inspired many X-Unit clones Available on all Smalltalk implementations Current Smalltalk version is 3.1 – stable but no recent development work Many popular frameworks ship with SUnit tests. So how are tests in the wild?
  • 5. Sample SUnit Result Very minimal indication of the cause of the failure
  • 6. Sample SUnit Result Slightly improved failure indication in the status bar via “Intelli-Dolphin” but still not particularly helpful
  • 7. So what’s wrong with this? Generic style tests require using a debugger to find out the problem The error displayed the in SUnit Runner is not very descriptive/helpful Not bad when doing initial TDD, but if mass failures afterwards, can be tedious to track down a problem Not always clear that you got the failure you expected unless you take the time to debug Erwin Reichstein (Carleton University – undergrad CS) “If you don’t find any errors in your code – you should be very worried”
  • 8. How about writing tests a different way? Concisely indicate your test intent, and leverage this information to give clear messages for inevitable failure…
  • 9. And presenting test results more usefully? Constraint provides a much clearer indication of the error
  • 10. SUnit Issues that cropped up… TestResults do not store the exception that causes them Therefore a UI has no additional information to report If you store the exception, how can you get a meaningful message from it?
  • 11. Expressing Expectations as Objects Create a family of Constraint objects with a protocol: #satisfies: #verifyWith: #errorMessageFor: #printAbbreviationOn: Try to use readable terminology for instantiation Equal to: Less than: Loose methods for convenience of instantiation #shouldEqual:
  • 13. More Complex Constraints constraint := (Begins with: 'p') | (Ends with: ‘s') & [:i | i size < 5]. In using constraints, discovered some useful new patterns: (Begins with: 'p') & Different values. Only values: #(‘peter’ ‘john’) Sequence of: #(‘peter’ ‘john’ ‘harry’) Leverage these objects to generate more specific error messages: “john not item 1 in #(‘peter’ ‘john’ ‘harry’)
  • 14. Do constraints have other users? Yes - Specifying expected values on method calls for testing: MethodWrappers MockObjects Code generation
  • 15. Example of a test using Mocks and Constraints ObjectDocumentor SUnitTest Reporter SUnitNameParser Use Constraints ( ) to verify each invocation to a proxy object
  • 16. Example Mock test using constraints testDoesntProcessNonTestMethods |report nameParser methods documentor| methods := #('setUp' 'testCalculates'). nameParser := mockery createMock: #SUnitNameParser. report := mockery createMock: #ResponsibilityReport. documentor := ObjectDocumentor new. [documentor process: methods using: nameParser onto: report] expecting: ([nameParser isTestMethod: (Only values: methods)] answerWith: #(false true)) + ([nameParser parse: 'testCalculates'] answer: 'Calculates' exactly: 1) + [report printResponsibility: (Kind of: String) &~ (Begins with: 'test')] once
  • 17. Generating Code from tests…. Run the tests, gather all the mock objects used, ask them to generate code, protocols, comments.
  • 18. Future Work Keep gathering useful constraints (like Sequence, Different etc.) Investigate if constraints can improve code generation (beyond simplistic usages) Investigate whether constraints can infer missing or conflicting test cases
  • 20. Summary When a test fails – ask yourself: Is it telling me everything it can about the failure? Would expressing it as a test constraint make it clearer? Speaker: Tim Mackinnon http://www.iterex.co.uk/research
  • 21. Related Work James Robertson’s Daily Smalltalk: ComplexConditions (http://www.cincomsmalltalk.com/casts/stDaily/2007/smalltalk_da ily-08-15-07.html)
  • 22. Acknowledgements Blaine Buxton/Brian Rice for encouragement at STS2006 Nat Pryce for introducing me to the idea of constraints as objects
  • 23. Tim Mackinnon - Who are you? 1996 – OTI Developer on teams credited for early use of agile practices 1999 – Connextra Formed one of the first Agile teams in the UK Invented “Mock Objects” test technique Pioneered Iteration/Heartbeat Retrospectives 2003 – ThoughtWorks Agile enablement coaching Established hi-level release estimation techniques Developed worldwide QuickStart project workshops 2006 – Iterative Excellence Tailored Consulting for Agile projects Iterex Professional – Software helping teams plan and track agile projects