SlideShare a Scribd company logo
1 of 56
Better Tests
Automagically
@leifwickland
@leifwickland
Unit tests:
1. Happy path
2. Failing path (maybe?)
3. Ship it!
Good arguments for that
● Finite time for writing tests
● Maintaining test code is expensive
● I’m just not that creative
How hard do you test edge cases?
● Test with Unicode most days?
● Insert control characters into strings?
● Throw negative values at your numbers?
● Toss empty containers at utility functions?
● Combine multiple edge cases in one test?
Typical Unit Testing Flow
1. You provide code of questionable quality
2. You provide input values to your functions
3. You hope not comically misrepresentative
4. You use the values to do something useful
5. You verify useful thing has expected result
Examples are expedient, not good
Better Tests Automagically
● Property Testing
● Generative Testing
● Randomized Testing
Typical Unit Testing Flow
1. You provide code of questionable quality
2. You provide input values to your functions
3. You hope not comically misrepresentative
4. You use the values to do something useful
5. You verify useful thing has expected result
Enter Property Testing
1. You provide code of questionable quality
2. You provide specification of kinds of inputs
3. It provides values to kick your butt
4. You use the values to do something useful
5. You verify useful thing has expected result
When to Use Property Tests
● Not always
● Natural round-tripping, symmetric functions
o Serialization/Deserialization
o Protocols
● Two equivalent algorithms
● Natural invariants
● General utility functions
o May need to resort to heuristic
What’s not to Like?
● Relatively slow to execute
● More to to get a basic level of coverage
● Documentation tends to be thin
Can I Use Property Testing?
● Scala
● Haskell
● JavaScript
● Ruby
● Python
● C# and .NET
● Java
● Closure
Others too!
From this old list
Questions?

More Related Content

What's hot

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Samnang Chhun
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit Testing
Søren Lund
 

What's hot (20)

Bahaviour Driven Development
Bahaviour Driven DevelopmentBahaviour Driven Development
Bahaviour Driven Development
 
Being Lean Agile
Being Lean AgileBeing Lean Agile
Being Lean Agile
 
Agile Testing!
Agile Testing!Agile Testing!
Agile Testing!
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review Process
 
Developer + tester = quality++
Developer + tester = quality++Developer + tester = quality++
Developer + tester = quality++
 
Insprint automation, build the culture
Insprint automation, build the cultureInsprint automation, build the culture
Insprint automation, build the culture
 
Please review and merge
Please review and mergePlease review and merge
Please review and merge
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Concurrent Applications with F# Agents
Concurrent Applications with F# AgentsConcurrent Applications with F# Agents
Concurrent Applications with F# Agents
 
5 levels of api test automation
5 levels of api test automation5 levels of api test automation
5 levels of api test automation
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
 
Improve your development skills with Test Driven Development
Improve your development skills with Test Driven DevelopmentImprove your development skills with Test Driven Development
Improve your development skills with Test Driven Development
 
Finding a good development partner
Finding a good development partnerFinding a good development partner
Finding a good development partner
 
NTHU Natural Language Processing Term Project Intro
NTHU Natural Language Processing Term Project IntroNTHU Natural Language Processing Term Project Intro
NTHU Natural Language Processing Term Project Intro
 
Basics of writing clean code
Basics of writing clean codeBasics of writing clean code
Basics of writing clean code
 
Everyone loves release notes!
Everyone loves release notes!Everyone loves release notes!
Everyone loves release notes!
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit Testing
 
Five steps towards your testing dream
Five steps towards your testing dreamFive steps towards your testing dream
Five steps towards your testing dream
 

Viewers also liked

Hotel site information copy 2
Hotel site information copy 2Hotel site information copy 2
Hotel site information copy 2
Sandra Lawn
 
McKinney_Greg_ES_342_Final_Project
McKinney_Greg_ES_342_Final_ProjectMcKinney_Greg_ES_342_Final_Project
McKinney_Greg_ES_342_Final_Project
Gregory McKinney
 

Viewers also liked (14)

Chris Omland - AWS Code Deploy - BSDC 2016
Chris Omland - AWS Code Deploy - BSDC 2016Chris Omland - AWS Code Deploy - BSDC 2016
Chris Omland - AWS Code Deploy - BSDC 2016
 
Will Price - Venture Capital in Montana - BSDC 2016
Will Price - Venture Capital in Montana - BSDC 2016Will Price - Venture Capital in Montana - BSDC 2016
Will Price - Venture Capital in Montana - BSDC 2016
 
Property.CoZa Introduction - Roadshow - September 2015
Property.CoZa Introduction - Roadshow - September 2015Property.CoZa Introduction - Roadshow - September 2015
Property.CoZa Introduction - Roadshow - September 2015
 
Ben Werner - Mountains and startups
Ben Werner - Mountains and startupsBen Werner - Mountains and startups
Ben Werner - Mountains and startups
 
Josef Verbanac - Voice is (a) Best Practice
Josef Verbanac - Voice is (a) Best PracticeJosef Verbanac - Voice is (a) Best Practice
Josef Verbanac - Voice is (a) Best Practice
 
Jason Moore - Why releasing 50 features are less than 1 solution - BSDC 2016
Jason Moore - Why releasing 50 features are less than 1 solution - BSDC 2016Jason Moore - Why releasing 50 features are less than 1 solution - BSDC 2016
Jason Moore - Why releasing 50 features are less than 1 solution - BSDC 2016
 
Hotel site information copy 2
Hotel site information copy 2Hotel site information copy 2
Hotel site information copy 2
 
HKR 3220: Routes
HKR 3220: RoutesHKR 3220: Routes
HKR 3220: Routes
 
Emergence Of Code Schools
Emergence Of Code SchoolsEmergence Of Code Schools
Emergence Of Code Schools
 
Nora McDougall-Collins - I Can Do That
Nora McDougall-Collins - I Can Do ThatNora McDougall-Collins - I Can Do That
Nora McDougall-Collins - I Can Do That
 
Best Logo Design Deal Ever
Best Logo Design Deal EverBest Logo Design Deal Ever
Best Logo Design Deal Ever
 
McKinney_Greg_ES_342_Final_Project
McKinney_Greg_ES_342_Final_ProjectMcKinney_Greg_ES_342_Final_Project
McKinney_Greg_ES_342_Final_Project
 
Jason Moore - Interaction design in enterprise teams
Jason Moore - Interaction design in enterprise teamsJason Moore - Interaction design in enterprise teams
Jason Moore - Interaction design in enterprise teams
 
Pete Sveen - How to Build, Grow, and Monetize Your Online Platform - BSDC 2016
Pete Sveen - How to Build, Grow, and Monetize Your Online Platform - BSDC 2016Pete Sveen - How to Build, Grow, and Monetize Your Online Platform - BSDC 2016
Pete Sveen - How to Build, Grow, and Monetize Your Online Platform - BSDC 2016
 

Similar to Better tests automagically (big sky dev con 2015)

Test automation expert days
Test automation   expert daysTest automation   expert days
Test automation expert days
Oren Rubin
 

Similar to Better tests automagically (big sky dev con 2015) (20)

Developer Testing
Developer TestingDeveloper Testing
Developer Testing
 
Software testing and quality assurance
Software testing and quality assuranceSoftware testing and quality assurance
Software testing and quality assurance
 
Property-based testing an open-source compiler, pflua (FOSDEM 2015)
Property-based testing an open-source compiler, pflua (FOSDEM 2015)Property-based testing an open-source compiler, pflua (FOSDEM 2015)
Property-based testing an open-source compiler, pflua (FOSDEM 2015)
 
Software Testing Basic Concepts
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Concepts
 
Pragmatic Introduction to Python Unit Testing (PyDays 2018)
Pragmatic Introduction to Python Unit Testing (PyDays 2018)Pragmatic Introduction to Python Unit Testing (PyDays 2018)
Pragmatic Introduction to Python Unit Testing (PyDays 2018)
 
Indy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-mule
 
Effective Unit Testing
Effective Unit TestingEffective Unit Testing
Effective Unit Testing
 
Fast end-to-end-tests
Fast end-to-end-testsFast end-to-end-tests
Fast end-to-end-tests
 
Super fast end-to-end-tests
Super fast end-to-end-testsSuper fast end-to-end-tests
Super fast end-to-end-tests
 
JUnit Boot Camp (GeeCON 2016)
JUnit Boot Camp (GeeCON 2016)JUnit Boot Camp (GeeCON 2016)
JUnit Boot Camp (GeeCON 2016)
 
Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)
 
TDD and Getting Paid
TDD and Getting PaidTDD and Getting Paid
TDD and Getting Paid
 
Automated UI testing done right (DDDSydney)
Automated UI testing done right (DDDSydney)Automated UI testing done right (DDDSydney)
Automated UI testing done right (DDDSydney)
 
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
 
Tdd
TddTdd
Tdd
 
Test automation expert days
Test automation   expert daysTest automation   expert days
Test automation expert days
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy Code
 
Let's test!
Let's test!Let's test!
Let's test!
 
Getting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud ShaonGetting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud Shaon
 
Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven Development
 

Better tests automagically (big sky dev con 2015)

  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. Unit tests: 1. Happy path 2. Failing path (maybe?) 3. Ship it!
  • 11.
  • 12. Good arguments for that ● Finite time for writing tests ● Maintaining test code is expensive ● I’m just not that creative
  • 13. How hard do you test edge cases? ● Test with Unicode most days? ● Insert control characters into strings? ● Throw negative values at your numbers? ● Toss empty containers at utility functions? ● Combine multiple edge cases in one test?
  • 14.
  • 15. Typical Unit Testing Flow 1. You provide code of questionable quality 2. You provide input values to your functions 3. You hope not comically misrepresentative 4. You use the values to do something useful 5. You verify useful thing has expected result
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22. Better Tests Automagically ● Property Testing ● Generative Testing ● Randomized Testing
  • 23. Typical Unit Testing Flow 1. You provide code of questionable quality 2. You provide input values to your functions 3. You hope not comically misrepresentative 4. You use the values to do something useful 5. You verify useful thing has expected result
  • 24. Enter Property Testing 1. You provide code of questionable quality 2. You provide specification of kinds of inputs 3. It provides values to kick your butt 4. You use the values to do something useful 5. You verify useful thing has expected result
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53. When to Use Property Tests ● Not always ● Natural round-tripping, symmetric functions o Serialization/Deserialization o Protocols ● Two equivalent algorithms ● Natural invariants ● General utility functions o May need to resort to heuristic
  • 54. What’s not to Like? ● Relatively slow to execute ● More to to get a basic level of coverage ● Documentation tends to be thin
  • 55. Can I Use Property Testing? ● Scala ● Haskell ● JavaScript ● Ruby ● Python ● C# and .NET ● Java ● Closure Others too! From this old list