SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Generating Unit Tests Based
on User Logs
Rick Wicker
Merrill Lynch – Global Markets
What is the goal of automated tests?
• Automated tests make sure that your code acts as it did previously
• Unless you are doing TDD
• They make it possible to identify where change has occurred
• We look at the failure and decide if that change was desired
• bug or new feature?
• We then make use these changed locations to target manual tests
Improving unit test coverage is hard
• Components are not testable
• Tests are often fragile
• How do you maximize the benefit of tests you write?
• Bad tests waste time with false positives
• Difficult to understand tests are difficult to use
• Tests take time to write
• Tests take time to maintain
• Data requirements
What show our tests be doing?
https://www.youtube.com/watch?v=URSWYvyc42M
"The Magic Tricks of Testing" by Sandi Metz
Inputs + Code + External State= Results
• Input is known
• We own our user entry points
• Code is static
• I hope, please use source control
• External state is always changing
• How much set up do you need to reproduce a given result
• Results can vary
• If only we could control state
How do we identify our inputs?
• Watch/ask users
• Guess
• Documentation
• Check logs when something doesn’t work
How do we identify our external state?
• Snapshots
• Guesses (logical and black arts)
• Log inferences
Great logs make production support easier
• Quickly identify user actions to reproduce failures
• Proactively identify user issues
• Understand what your users are doing in your application
• Log anything needed to reproduce that user action (except for
external state)
Can we recreate I+C+ES=R
• Input
• yes, we have logs
• Code
• yes, we have source control
• External State
• sometimes?
• Results
• If we know External State
Re-creating external state
• Simplify the moving parts
• Identify inputs
• Simulate outputs
• Input= Select Count(*) from Sometable
• Output = 42
• Log the inputs, log enough of the output to be able to rebuild relevant output
• I can log 42
• I can log 1 row
• I maybe can’t log 100 rows, but I can log enough metadata to reproduce them in a
meaningful way
• External State becomes a simple function: inputs + result metadata = outputs
• Create a data layer and track everything coming through
How do I use this for testing?
• Log
• user actions
• External system inputs
• External system output metadata
• Curate
• Remove – actions probably have lots of duplication
• Replace – sometimes things should change
• Add – new functionality, test it manually and then add it to your test suite
• Simulate
• Swap out data layer
• Return simulated responses based on inputs and metadata collected in live systems
• Validate
• Compare simulated inputs vs logged inputs
• Compare simulation output against simulation output from known good source (i.e. prod)
• Add a simulation api
Where would this help?
• Legacy applications not written for testability
• Too many code paths to keep track of
• See #1
• Application usage is not well understood
• don’t know what critical functionality is handled by users
• Application dependencies are not well understood
• Wide and shallow applications
• Very focused applications tend to have changes which affect a higher
percentage of tests – which invalidates too many tests every time
Concept references
• Use current production as a model for tests
• http://githubengineering.com/scientist/
• What should be tested?
• Magic Tricks of Testing by Sandi Metz -
https://www.youtube.com/watch?v=URSWYvyc42M
• Working Effectively with Legacy Code by Michael Feathers

Weitere ähnliche Inhalte

Was ist angesagt?

Diffy : Automatic Testing of Microservices @ Twitter
Diffy : Automatic Testing of Microservices @ TwitterDiffy : Automatic Testing of Microservices @ Twitter
Diffy : Automatic Testing of Microservices @ Twitter
Puneet Khanduri
 

Was ist angesagt? (20)

Bug prediction based on your code history
Bug prediction based on your code historyBug prediction based on your code history
Bug prediction based on your code history
 
Eurosport's Kodakademi #2
Eurosport's Kodakademi #2Eurosport's Kodakademi #2
Eurosport's Kodakademi #2
 
The Art of Giving and Receiving Code Reviews
The Art of Giving and Receiving Code ReviewsThe Art of Giving and Receiving Code Reviews
The Art of Giving and Receiving Code Reviews
 
Continuous Integration: Finding problems soonest
Continuous Integration: Finding problems soonestContinuous Integration: Finding problems soonest
Continuous Integration: Finding problems soonest
 
Flow control in Python
Flow control in PythonFlow control in Python
Flow control in Python
 
Twelve Factor - Designing for Change
Twelve Factor - Designing for ChangeTwelve Factor - Designing for Change
Twelve Factor - Designing for Change
 
Unit testing
Unit testingUnit testing
Unit testing
 
Testing sync engine
Testing sync engineTesting sync engine
Testing sync engine
 
SDLC. QA Role
SDLC. QA RoleSDLC. QA Role
SDLC. QA Role
 
Resilience and chaos engineering
Resilience and chaos engineeringResilience and chaos engineering
Resilience and chaos engineering
 
Useful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmUseful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvm
 
Finding Defects in C#: Coverity vs. FxCop
Finding Defects in C#: Coverity vs. FxCopFinding Defects in C#: Coverity vs. FxCop
Finding Defects in C#: Coverity vs. FxCop
 
Bug prediction + sdlc automation
Bug prediction + sdlc automationBug prediction + sdlc automation
Bug prediction + sdlc automation
 
Tech Days 2015: Static Analysis CodePeer
Tech Days 2015: Static Analysis CodePeer Tech Days 2015: Static Analysis CodePeer
Tech Days 2015: Static Analysis CodePeer
 
Diffy : Automatic Testing of Microservices @ Twitter
Diffy : Automatic Testing of Microservices @ TwitterDiffy : Automatic Testing of Microservices @ Twitter
Diffy : Automatic Testing of Microservices @ Twitter
 
What is eggPlant Functional?
What is eggPlant Functional?What is eggPlant Functional?
What is eggPlant Functional?
 
How to Use Innoslate for Beginners
How to Use Innoslate for BeginnersHow to Use Innoslate for Beginners
How to Use Innoslate for Beginners
 
Get Testing with tSQLt - SQL In The City Workshop 2014
Get Testing with tSQLt - SQL In The City Workshop 2014Get Testing with tSQLt - SQL In The City Workshop 2014
Get Testing with tSQLt - SQL In The City Workshop 2014
 
How to improve your Tizen native program
How to improve your Tizen native programHow to improve your Tizen native program
How to improve your Tizen native program
 
Careful - APIs Inside: Testing and Monitoring for App Development
Careful - APIs Inside: Testing and Monitoring for App DevelopmentCareful - APIs Inside: Testing and Monitoring for App Development
Careful - APIs Inside: Testing and Monitoring for App Development
 

Ähnlich wie Generating unit tests based on user logs

Pekka_Aho_Complementing GUI Testing Scripts - Testing Assembly 2022.pdf
Pekka_Aho_Complementing GUI Testing Scripts -  Testing Assembly 2022.pdfPekka_Aho_Complementing GUI Testing Scripts -  Testing Assembly 2022.pdf
Pekka_Aho_Complementing GUI Testing Scripts - Testing Assembly 2022.pdf
FiSTB
 
Introduction to-automated-testing
Introduction to-automated-testingIntroduction to-automated-testing
Introduction to-automated-testing
BestBrains
 

Ähnlich wie Generating unit tests based on user logs (20)

Making a Mock by Kelsey Shannahan
Making a Mock by Kelsey ShannahanMaking a Mock by Kelsey Shannahan
Making a Mock by Kelsey Shannahan
 
DBmaestro's State of the Database Continuous Delivery Survey- Findings Revealed
DBmaestro's State of the Database Continuous Delivery Survey- Findings RevealedDBmaestro's State of the Database Continuous Delivery Survey- Findings Revealed
DBmaestro's State of the Database Continuous Delivery Survey- Findings Revealed
 
An Introduction To Software Development - Testing, Continuous integration
An Introduction To Software Development - Testing, Continuous integrationAn Introduction To Software Development - Testing, Continuous integration
An Introduction To Software Development - Testing, Continuous integration
 
An Introduction To Software Development - Final Review
An Introduction To Software Development - Final ReviewAn Introduction To Software Development - Final Review
An Introduction To Software Development - Final Review
 
The Future of AI-Based Test Automation
The Future of AI-Based Test AutomationThe Future of AI-Based Test Automation
The Future of AI-Based Test Automation
 
Behavior-Driven Development (BDD) Testing with Apache Spark with Aaron Colcor...
Behavior-Driven Development (BDD) Testing with Apache Spark with Aaron Colcor...Behavior-Driven Development (BDD) Testing with Apache Spark with Aaron Colcor...
Behavior-Driven Development (BDD) Testing with Apache Spark with Aaron Colcor...
 
Work Unit Analysis Tool
Work Unit Analysis ToolWork Unit Analysis Tool
Work Unit Analysis Tool
 
Performance Tuning in the Trenches
Performance Tuning in the TrenchesPerformance Tuning in the Trenches
Performance Tuning in the Trenches
 
TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)
 
Avoiding test hell
Avoiding test hellAvoiding test hell
Avoiding test hell
 
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
 
In (database) automation we trust
In (database) automation we trustIn (database) automation we trust
In (database) automation we trust
 
Kku2011
Kku2011Kku2011
Kku2011
 
Pekka_Aho_Complementing GUI Testing Scripts - Testing Assembly 2022.pdf
Pekka_Aho_Complementing GUI Testing Scripts -  Testing Assembly 2022.pdfPekka_Aho_Complementing GUI Testing Scripts -  Testing Assembly 2022.pdf
Pekka_Aho_Complementing GUI Testing Scripts - Testing Assembly 2022.pdf
 
Improving The Quality of Existing Software
Improving The Quality of Existing SoftwareImproving The Quality of Existing Software
Improving The Quality of Existing Software
 
Introduction to Automated Testing
Introduction to Automated TestingIntroduction to Automated Testing
Introduction to Automated Testing
 
Introduction to-automated-testing
Introduction to-automated-testingIntroduction to-automated-testing
Introduction to-automated-testing
 
Agile Software Testing the Agilogy Way
Agile Software Testing the Agilogy WayAgile Software Testing the Agilogy Way
Agile Software Testing the Agilogy Way
 
An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit Testing
 
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald BelchamGetting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
 

Kürzlich hochgeladen

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Kürzlich hochgeladen (20)

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 

Generating unit tests based on user logs

  • 1. Generating Unit Tests Based on User Logs Rick Wicker Merrill Lynch – Global Markets
  • 2. What is the goal of automated tests? • Automated tests make sure that your code acts as it did previously • Unless you are doing TDD • They make it possible to identify where change has occurred • We look at the failure and decide if that change was desired • bug or new feature? • We then make use these changed locations to target manual tests
  • 3. Improving unit test coverage is hard • Components are not testable • Tests are often fragile • How do you maximize the benefit of tests you write? • Bad tests waste time with false positives • Difficult to understand tests are difficult to use • Tests take time to write • Tests take time to maintain • Data requirements
  • 4. What show our tests be doing? https://www.youtube.com/watch?v=URSWYvyc42M "The Magic Tricks of Testing" by Sandi Metz
  • 5. Inputs + Code + External State= Results • Input is known • We own our user entry points • Code is static • I hope, please use source control • External state is always changing • How much set up do you need to reproduce a given result • Results can vary • If only we could control state
  • 6. How do we identify our inputs? • Watch/ask users • Guess • Documentation • Check logs when something doesn’t work
  • 7. How do we identify our external state? • Snapshots • Guesses (logical and black arts) • Log inferences
  • 8. Great logs make production support easier • Quickly identify user actions to reproduce failures • Proactively identify user issues • Understand what your users are doing in your application • Log anything needed to reproduce that user action (except for external state)
  • 9. Can we recreate I+C+ES=R • Input • yes, we have logs • Code • yes, we have source control • External State • sometimes? • Results • If we know External State
  • 10. Re-creating external state • Simplify the moving parts • Identify inputs • Simulate outputs • Input= Select Count(*) from Sometable • Output = 42 • Log the inputs, log enough of the output to be able to rebuild relevant output • I can log 42 • I can log 1 row • I maybe can’t log 100 rows, but I can log enough metadata to reproduce them in a meaningful way • External State becomes a simple function: inputs + result metadata = outputs • Create a data layer and track everything coming through
  • 11. How do I use this for testing? • Log • user actions • External system inputs • External system output metadata • Curate • Remove – actions probably have lots of duplication • Replace – sometimes things should change • Add – new functionality, test it manually and then add it to your test suite • Simulate • Swap out data layer • Return simulated responses based on inputs and metadata collected in live systems • Validate • Compare simulated inputs vs logged inputs • Compare simulation output against simulation output from known good source (i.e. prod) • Add a simulation api
  • 12. Where would this help? • Legacy applications not written for testability • Too many code paths to keep track of • See #1 • Application usage is not well understood • don’t know what critical functionality is handled by users • Application dependencies are not well understood • Wide and shallow applications • Very focused applications tend to have changes which affect a higher percentage of tests – which invalidates too many tests every time
  • 13. Concept references • Use current production as a model for tests • http://githubengineering.com/scientist/ • What should be tested? • Magic Tricks of Testing by Sandi Metz - https://www.youtube.com/watch?v=URSWYvyc42M • Working Effectively with Legacy Code by Michael Feathers