SlideShare a Scribd company logo
1 of 34
Download to read offline
Testing: Cable and Chain
Questions To Answer
• Are tests helping or hurting your ability to code?
• Why progress slows with complexity?
About me
• Built and Maintained 100K membership site for ~8 year
• Built and Maintained a highly rated Scrum Training
Application for ~12 years
• Elixir: CC Processing, Medical Research, Energy Grid
• Unit testing TDD since 1999 — sUnit !
• Learned from Kent Beck and Bob Martin
Types of Tests
• Technical
• Unit - Links
• Integration - Cables
• Performance
• Security
• User
• Acceptance Tests - Checks Behavior
• Is it done (Unit or Integration)
Cable connect two points
Make sure that
UI and DB are connected.
Integration Tests are Cables
Integration Tests
• Test that things connect
correctly
• Not that they perform
business tasks
cables()
:ok
• Keep them Minimal
• As few as possible
to prove that things
connect
Photo by Samuel Zeller on UnSplash
cables()
{:error, “update failed”}
• Hard to change
• Slow you down
• False Positive
Coverage
reporting
Photo by Martijn Baudoin on UnSplash
Incidental Coverage
• Need code example …
A chain is made up of links.
Each Link does a separate job.
If each link is strong,
the chain will be strong.
Unit Tests are Chain Links
Unit Tests
• Assert every possible
thing that the function
can do
• Every branch and
behavior
• Link must be Strong
and Reliable
Types of Tests
• Technical
• Unit - Links - Checks Logic
• Integration - Cables - Checks Connections
• Performance
• User
• Acceptance Tests - Checks Behavior
• Is it done (Could be Unit or Integration)
Testing approach
1. Test every link throughly - Unit
2. Test that every link can connect - Integration
What is a Unit ?
Not a unit test IF
• It can't run in parallel with other unit tests
• It touches or needs …
• Database
• Network
• File system
• Environment - like config files
- A Set of Unit Testing Rules By Michael Feathers 2005
Things in Environment
• System Time
• Global Application.get_env
• Erlang Scheduler, so no multi-
processes tests
- A Set of Unit Testing Rules By Michael Feathers 2005
Code Under Test
Should have no Side Effects
Side-effects
• A function has a side effect if
• it modifies a mutable data structure or
variable
• uses IO
• throws an exception
https://dzone.com/articles/side-effects-1
Functional Programming
• … functions should not have side effects
• A function with side effects
• is called a Procedure
• can be unpredictable depending on the state
of the system
• is hard to test
https://dzone.com/articles/side-effects-1
Functions with no
Side-Effects are called
Pure Functions
They are good !
no observable side effects
Pure Functions are easy to test
Tests for Pure Functions are
Unit Tests
But what if the function
needs to talk to something ?
Higher-Order Functions
• Functions that take functions as params, or return
functions
To the Rescue !
inc_function = fn(n) -> n + 1 end
Enum.map( [ 1, 2, 3 ] , inc_function )
Test with Injection
• Needs Code example …
Refactor:
“Move Side-Effect Up”
• Needs Code Example …
Are your Tests … Large?
Using the DB?
You might be Bound in Cables
hard to write?
The Environment?
How do I Build Small tests ?
Try,
Test Driven Development
• From XP - ExtremeProgramming created in ~1997
• Inside out - Detroit style
• Outside in - London style
• Red - Green - Refactor, 5-10 mins & commit
Test Doubles
Test Double (think stunt double) is a generic term
• Dummies: passed around but never used. Fill parameter lists.
• Fakes: working implementations, like InMemoryTestDatabase.
• Stubs: canned answers to calls.
• Spies: Stubs that also record information. like An email service Stub that counts
messages sent.
• Mocks are pre-programmed with expectations which form a specification of the
calls they are expected to receive. They can throw an exception if they receive a
call they don't expect and are checked during verification to ensure they got all the
calls they were expecting.
- TestDouble, Bliki, by Martin Fowler, 2006
Independent Tests
• Easy to change, only touches Collaborators
• Rule #1: Only TestDouble for Collaborators
Local Stubs
Aka, “Mocks As Locals”
Although we have used the application configuration for
solving the external API issue,
sometimes it is easier to just pass the dependency as
argument. Imagine this example in Elixir where some
function may perform heavy work which you want to
isolate in tests
— José Valim
http://blog.plataformatec.com.br/2015/10/mocks-and-explicit-contracts/
Prefer Local Stubs
passing the dependency as argument is
much simpler and should be preferred
over relying on configuration files and
Application.get_env/3
— José Valim
http://blog.plataformatec.com.br/2015/10/mocks-and-explicit-contracts/
Test Reflector
• See README.md
• Needs Fuller Code Examples …
•
test "using the Reflector to remove slow or side-effect dependency" do
stubbed_data = "Something just for the test"
MyRepoReflector.stash_some_data_i_need({:ok, stubbed_data})
# When
result = TargetCode.something(234, MyRepoReflector)
assert {:ok, "Something just for the test234"} == result
assert_receive :some_data_i_need
end
2020-Feb: Testing: Cables and Chains

More Related Content

What's hot

Leandro Melendez - Switching Performance Left & Right
Leandro Melendez - Switching Performance Left & RightLeandro Melendez - Switching Performance Left & Right
Leandro Melendez - Switching Performance Left & RightNeotys_Partner
 
MongoDB World 2018: Tutorial - MongoDB Meets Chaos Monkey
MongoDB World 2018: Tutorial - MongoDB Meets Chaos MonkeyMongoDB World 2018: Tutorial - MongoDB Meets Chaos Monkey
MongoDB World 2018: Tutorial - MongoDB Meets Chaos MonkeyMongoDB
 
Making testability our mission
Making testability our missionMaking testability our mission
Making testability our missionAsh Winter
 
Walking Skeleton
Walking SkeletonWalking Skeleton
Walking Skeletonhepphep
 
TDD on android. Why and How? (Coding Serbia 2019)
TDD on android. Why and How? (Coding Serbia 2019)TDD on android. Why and How? (Coding Serbia 2019)
TDD on android. Why and How? (Coding Serbia 2019)Danny Preussler
 
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.NET Conf UY
 
Completely Test-Driven
Completely Test-DrivenCompletely Test-Driven
Completely Test-DrivenIan Truslove
 
TestDriven Development, Why How and Smells
TestDriven Development, Why How and SmellsTestDriven Development, Why How and Smells
TestDriven Development, Why How and SmellsProwareness
 
Solano Labs presented at MassTLC's automated testing
Solano Labs presented at MassTLC's automated testingSolano Labs presented at MassTLC's automated testing
Solano Labs presented at MassTLC's automated testingMassTLC
 
Rapid Performance Testing: No Load Generation Required
Rapid Performance Testing: No Load Generation RequiredRapid Performance Testing: No Load Generation Required
Rapid Performance Testing: No Load Generation RequiredTechWell
 
Next Level Unit Testing - Javacro 2019 - Dominik Poljak
Next Level Unit Testing - Javacro 2019 - Dominik PoljakNext Level Unit Testing - Javacro 2019 - Dominik Poljak
Next Level Unit Testing - Javacro 2019 - Dominik PoljakDominik Poljak
 
An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit TestingSahar Nofal
 
Power-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua RussellPower-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua RussellQA or the Highway
 
Entity Framework: To the Unit of Work Design Pattern and Beyond
Entity Framework: To the Unit of Work Design Pattern and BeyondEntity Framework: To the Unit of Work Design Pattern and Beyond
Entity Framework: To the Unit of Work Design Pattern and BeyondSteve Westgarth
 
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)Danny Preussler
 
I Don't Test Often ...
I Don't Test Often ...I Don't Test Often ...
I Don't Test Often ...Gareth Bowles
 
Seeding a Tree in a Gherkin
Seeding a Tree in a GherkinSeeding a Tree in a Gherkin
Seeding a Tree in a GherkinPaul Rohorzka
 
Twelve Factor - Designing for Change
Twelve Factor - Designing for ChangeTwelve Factor - Designing for Change
Twelve Factor - Designing for ChangeEric Wyles
 
Strategies in continuous delivery
Strategies in continuous deliveryStrategies in continuous delivery
Strategies in continuous deliveryAviran Mordo
 

What's hot (20)

Leandro Melendez - Switching Performance Left & Right
Leandro Melendez - Switching Performance Left & RightLeandro Melendez - Switching Performance Left & Right
Leandro Melendez - Switching Performance Left & Right
 
MongoDB World 2018: Tutorial - MongoDB Meets Chaos Monkey
MongoDB World 2018: Tutorial - MongoDB Meets Chaos MonkeyMongoDB World 2018: Tutorial - MongoDB Meets Chaos Monkey
MongoDB World 2018: Tutorial - MongoDB Meets Chaos Monkey
 
Making testability our mission
Making testability our missionMaking testability our mission
Making testability our mission
 
Walking Skeleton
Walking SkeletonWalking Skeleton
Walking Skeleton
 
TDD on android. Why and How? (Coding Serbia 2019)
TDD on android. Why and How? (Coding Serbia 2019)TDD on android. Why and How? (Coding Serbia 2019)
TDD on android. Why and How? (Coding Serbia 2019)
 
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
 
Completely Test-Driven
Completely Test-DrivenCompletely Test-Driven
Completely Test-Driven
 
TestDriven Development, Why How and Smells
TestDriven Development, Why How and SmellsTestDriven Development, Why How and Smells
TestDriven Development, Why How and Smells
 
Solano Labs presented at MassTLC's automated testing
Solano Labs presented at MassTLC's automated testingSolano Labs presented at MassTLC's automated testing
Solano Labs presented at MassTLC's automated testing
 
Rapid Performance Testing: No Load Generation Required
Rapid Performance Testing: No Load Generation RequiredRapid Performance Testing: No Load Generation Required
Rapid Performance Testing: No Load Generation Required
 
Next Level Unit Testing - Javacro 2019 - Dominik Poljak
Next Level Unit Testing - Javacro 2019 - Dominik PoljakNext Level Unit Testing - Javacro 2019 - Dominik Poljak
Next Level Unit Testing - Javacro 2019 - Dominik Poljak
 
An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit Testing
 
Power-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua RussellPower-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua Russell
 
Entity Framework: To the Unit of Work Design Pattern and Beyond
Entity Framework: To the Unit of Work Design Pattern and BeyondEntity Framework: To the Unit of Work Design Pattern and Beyond
Entity Framework: To the Unit of Work Design Pattern and Beyond
 
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)
 
I Don't Test Often ...
I Don't Test Often ...I Don't Test Often ...
I Don't Test Often ...
 
Seeding a Tree in a Gherkin
Seeding a Tree in a GherkinSeeding a Tree in a Gherkin
Seeding a Tree in a Gherkin
 
Twelve Factor - Designing for Change
Twelve Factor - Designing for ChangeTwelve Factor - Designing for Change
Twelve Factor - Designing for Change
 
Strategies in continuous delivery
Strategies in continuous deliveryStrategies in continuous delivery
Strategies in continuous delivery
 
Benefits from AATs
Benefits from AATsBenefits from AATs
Benefits from AATs
 

Similar to 2020-Feb: Testing: Cables and Chains

Improving Batch-Process Testing Techniques with a Domain-Specific Language
Improving Batch-Process Testing Techniques with a Domain-Specific LanguageImproving Batch-Process Testing Techniques with a Domain-Specific Language
Improving Batch-Process Testing Techniques with a Domain-Specific LanguageDr. Spock
 
Performance Tuning in the Trenches
Performance Tuning in the TrenchesPerformance Tuning in the Trenches
Performance Tuning in the TrenchesDonald Belcham
 
Type mock isolator
Type mock isolatorType mock isolator
Type mock isolatorMaslowB
 
Type mock isolator
Type mock isolatorType mock isolator
Type mock isolatorMaslowB
 
The Key Components of Adopting CI The OpenStack Way
The Key Components of Adopting CI The OpenStack WayThe Key Components of Adopting CI The OpenStack Way
The Key Components of Adopting CI The OpenStack WayiWeb (group INAP)
 
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Steven Smith
 
Agile Software Testing the Agilogy Way
Agile Software Testing the Agilogy WayAgile Software Testing the Agilogy Way
Agile Software Testing the Agilogy WayJordi Pradel
 
Rethinking Testing
Rethinking TestingRethinking Testing
Rethinking Testingpdejuan
 
Testing for Logic App Solutions | Integration Monday
Testing for Logic App Solutions | Integration MondayTesting for Logic App Solutions | Integration Monday
Testing for Logic App Solutions | Integration MondayBizTalk360
 
Test automation lessons from WebSphere Application Server
Test automation lessons from WebSphere Application ServerTest automation lessons from WebSphere Application Server
Test automation lessons from WebSphere Application ServerRobbie Minshall
 
190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
190711_Testbirds_Selenium_eclipsecon_FINAL_0.pptNaviAningi
 
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.pptKKSD_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.pptKiran Kumar SD
 
How To Build an Effective Automated Test Suite
How To Build an Effective Automated Test SuiteHow To Build an Effective Automated Test Suite
How To Build an Effective Automated Test SuiteDavid Adsit
 

Similar to 2020-Feb: Testing: Cables and Chains (20)

Unit testing
Unit testingUnit testing
Unit testing
 
Improving Batch-Process Testing Techniques with a Domain-Specific Language
Improving Batch-Process Testing Techniques with a Domain-Specific LanguageImproving Batch-Process Testing Techniques with a Domain-Specific Language
Improving Batch-Process Testing Techniques with a Domain-Specific Language
 
Testing Angular
Testing AngularTesting Angular
Testing Angular
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Performance Tuning in the Trenches
Performance Tuning in the TrenchesPerformance Tuning in the Trenches
Performance Tuning in the Trenches
 
Ch11lect1 ud
Ch11lect1 udCh11lect1 ud
Ch11lect1 ud
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Type mock isolator
Type mock isolatorType mock isolator
Type mock isolator
 
Type mock isolator
Type mock isolatorType mock isolator
Type mock isolator
 
Presentation delex
Presentation delexPresentation delex
Presentation delex
 
The Key Components of Adopting CI The OpenStack Way
The Key Components of Adopting CI The OpenStack WayThe Key Components of Adopting CI The OpenStack Way
The Key Components of Adopting CI The OpenStack Way
 
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
 
Agile Software Testing the Agilogy Way
Agile Software Testing the Agilogy WayAgile Software Testing the Agilogy Way
Agile Software Testing the Agilogy Way
 
Rethinking Testing
Rethinking TestingRethinking Testing
Rethinking Testing
 
Testing for Logic App Solutions | Integration Monday
Testing for Logic App Solutions | Integration MondayTesting for Logic App Solutions | Integration Monday
Testing for Logic App Solutions | Integration Monday
 
Test automation lessons from WebSphere Application Server
Test automation lessons from WebSphere Application ServerTest automation lessons from WebSphere Application Server
Test automation lessons from WebSphere Application Server
 
190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
 
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.pptKKSD_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
 
NYC MeetUp 10.9
NYC MeetUp 10.9NYC MeetUp 10.9
NYC MeetUp 10.9
 
How To Build an Effective Automated Test Suite
How To Build an Effective Automated Test SuiteHow To Build an Effective Automated Test Suite
How To Build an Effective Automated Test Suite
 

More from Mark Windholtz

XP-Retro from Codemash.org Jan 2018
XP-Retro from Codemash.org Jan 2018XP-Retro from Codemash.org Jan 2018
XP-Retro from Codemash.org Jan 2018Mark Windholtz
 
Domain Driven Design Communication Techniques
Domain Driven Design Communication TechniquesDomain Driven Design Communication Techniques
Domain Driven Design Communication TechniquesMark Windholtz
 
Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15Mark Windholtz
 
Domain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic PatternsDomain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic PatternsMark Windholtz
 
Domain Driven Design - Building Blocks
Domain Driven Design - Building BlocksDomain Driven Design - Building Blocks
Domain Driven Design - Building BlocksMark Windholtz
 
War between Tools and Design 2016
War between Tools and Design 2016War between Tools and Design 2016
War between Tools and Design 2016Mark Windholtz
 
2019-Nov: Domain Driven Design (DDD) and when not to use it
2019-Nov: Domain Driven Design (DDD) and when not to use it2019-Nov: Domain Driven Design (DDD) and when not to use it
2019-Nov: Domain Driven Design (DDD) and when not to use itMark Windholtz
 
Planning XP - Extreme Programming
Planning XP - Extreme ProgrammingPlanning XP - Extreme Programming
Planning XP - Extreme ProgrammingMark Windholtz
 
2017 June AgileCincy Event Storming
2017 June AgileCincy Event Storming2017 June AgileCincy Event Storming
2017 June AgileCincy Event StormingMark Windholtz
 

More from Mark Windholtz (10)

XP-Retro from Codemash.org Jan 2018
XP-Retro from Codemash.org Jan 2018XP-Retro from Codemash.org Jan 2018
XP-Retro from Codemash.org Jan 2018
 
Domain Driven Design Communication Techniques
Domain Driven Design Communication TechniquesDomain Driven Design Communication Techniques
Domain Driven Design Communication Techniques
 
Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15
 
Domain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic PatternsDomain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic Patterns
 
Domain Driven Design - Building Blocks
Domain Driven Design - Building BlocksDomain Driven Design - Building Blocks
Domain Driven Design - Building Blocks
 
War between Tools and Design 2016
War between Tools and Design 2016War between Tools and Design 2016
War between Tools and Design 2016
 
2019-Nov: Domain Driven Design (DDD) and when not to use it
2019-Nov: Domain Driven Design (DDD) and when not to use it2019-Nov: Domain Driven Design (DDD) and when not to use it
2019-Nov: Domain Driven Design (DDD) and when not to use it
 
Planning XP - Extreme Programming
Planning XP - Extreme ProgrammingPlanning XP - Extreme Programming
Planning XP - Extreme Programming
 
2017 June AgileCincy Event Storming
2017 June AgileCincy Event Storming2017 June AgileCincy Event Storming
2017 June AgileCincy Event Storming
 
Planning XP
Planning XPPlanning XP
Planning XP
 

Recently uploaded

2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxSasikiranMarri
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxAS Design & AST.
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdfSteve Caron
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxRTS corp
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 

Recently uploaded (20)

2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptx
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptx
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 

2020-Feb: Testing: Cables and Chains

  • 2. Questions To Answer • Are tests helping or hurting your ability to code? • Why progress slows with complexity?
  • 3. About me • Built and Maintained 100K membership site for ~8 year • Built and Maintained a highly rated Scrum Training Application for ~12 years • Elixir: CC Processing, Medical Research, Energy Grid • Unit testing TDD since 1999 — sUnit ! • Learned from Kent Beck and Bob Martin
  • 4. Types of Tests • Technical • Unit - Links • Integration - Cables • Performance • Security • User • Acceptance Tests - Checks Behavior • Is it done (Unit or Integration)
  • 5. Cable connect two points Make sure that UI and DB are connected. Integration Tests are Cables
  • 6. Integration Tests • Test that things connect correctly • Not that they perform business tasks
  • 7. cables() :ok • Keep them Minimal • As few as possible to prove that things connect Photo by Samuel Zeller on UnSplash
  • 8. cables() {:error, “update failed”} • Hard to change • Slow you down • False Positive Coverage reporting Photo by Martijn Baudoin on UnSplash
  • 9. Incidental Coverage • Need code example …
  • 10. A chain is made up of links. Each Link does a separate job. If each link is strong, the chain will be strong. Unit Tests are Chain Links
  • 11. Unit Tests • Assert every possible thing that the function can do • Every branch and behavior • Link must be Strong and Reliable
  • 12. Types of Tests • Technical • Unit - Links - Checks Logic • Integration - Cables - Checks Connections • Performance • User • Acceptance Tests - Checks Behavior • Is it done (Could be Unit or Integration)
  • 13. Testing approach 1. Test every link throughly - Unit 2. Test that every link can connect - Integration
  • 14. What is a Unit ?
  • 15. Not a unit test IF • It can't run in parallel with other unit tests • It touches or needs … • Database • Network • File system • Environment - like config files - A Set of Unit Testing Rules By Michael Feathers 2005
  • 16. Things in Environment • System Time • Global Application.get_env • Erlang Scheduler, so no multi- processes tests - A Set of Unit Testing Rules By Michael Feathers 2005
  • 17. Code Under Test Should have no Side Effects
  • 18. Side-effects • A function has a side effect if • it modifies a mutable data structure or variable • uses IO • throws an exception https://dzone.com/articles/side-effects-1
  • 19. Functional Programming • … functions should not have side effects • A function with side effects • is called a Procedure • can be unpredictable depending on the state of the system • is hard to test https://dzone.com/articles/side-effects-1
  • 20. Functions with no Side-Effects are called Pure Functions They are good ! no observable side effects
  • 21. Pure Functions are easy to test Tests for Pure Functions are Unit Tests
  • 22. But what if the function needs to talk to something ?
  • 23. Higher-Order Functions • Functions that take functions as params, or return functions To the Rescue ! inc_function = fn(n) -> n + 1 end Enum.map( [ 1, 2, 3 ] , inc_function )
  • 24. Test with Injection • Needs Code example …
  • 26. Are your Tests … Large? Using the DB? You might be Bound in Cables hard to write? The Environment?
  • 27. How do I Build Small tests ?
  • 28. Try, Test Driven Development • From XP - ExtremeProgramming created in ~1997 • Inside out - Detroit style • Outside in - London style • Red - Green - Refactor, 5-10 mins & commit
  • 29. Test Doubles Test Double (think stunt double) is a generic term • Dummies: passed around but never used. Fill parameter lists. • Fakes: working implementations, like InMemoryTestDatabase. • Stubs: canned answers to calls. • Spies: Stubs that also record information. like An email service Stub that counts messages sent. • Mocks are pre-programmed with expectations which form a specification of the calls they are expected to receive. They can throw an exception if they receive a call they don't expect and are checked during verification to ensure they got all the calls they were expecting. - TestDouble, Bliki, by Martin Fowler, 2006
  • 30. Independent Tests • Easy to change, only touches Collaborators • Rule #1: Only TestDouble for Collaborators
  • 31. Local Stubs Aka, “Mocks As Locals” Although we have used the application configuration for solving the external API issue, sometimes it is easier to just pass the dependency as argument. Imagine this example in Elixir where some function may perform heavy work which you want to isolate in tests — José Valim http://blog.plataformatec.com.br/2015/10/mocks-and-explicit-contracts/
  • 32. Prefer Local Stubs passing the dependency as argument is much simpler and should be preferred over relying on configuration files and Application.get_env/3 — José Valim http://blog.plataformatec.com.br/2015/10/mocks-and-explicit-contracts/
  • 33. Test Reflector • See README.md • Needs Fuller Code Examples … • test "using the Reflector to remove slow or side-effect dependency" do stubbed_data = "Something just for the test" MyRepoReflector.stash_some_data_i_need({:ok, stubbed_data}) # When result = TargetCode.something(234, MyRepoReflector) assert {:ok, "Something just for the test234"} == result assert_receive :some_data_i_need end