SlideShare uma empresa Scribd logo
1 de 16
Unit Testing – The Prequel

Gil Zilberfeld, Product Manager
Jan 29th, 2013
@gil_zilberfeld
Prepare
• Know your tools
• Evaluate the risk
• Choose your partner

@gil_zilberfeld
Step 1: What to test
• What to test:
• What you’re
working on
• Bug or feature?
• Logic

• What not to test:
• Multithreading
• Stored procedures
• UI

@gil_zilberfeld
Step 2: Get ready
• Pick organization strategy
• Create test projects
• Remove fluff
• VS I’m looking at you

@gil_zilberfeld
Step 3: Pick a scenario
• Scenario:
• Context
• Action
• Success criteria
• Pick the simplest
one

• Say it!
• Name it!
• Assert it!

@gil_zilberfeld
How
code
looks

@gil_zilberfeld
Simple
path
test

@gil_zilberfeld
“Happy
path”
test

@gil_zilberfeld
Step 3: Pick a scenario
• Scenario:
• Context
• Logic
• Success criteria
• Pick the simplest
one

• Say it!
• Name it!
• Assert it!

@gil_zilberfeld
Step 4: Identify
dependencies
• Read the code
• Constructor
parameters
• Fields
• Statics
• Global state

• Mocking strategy
• None (Integration)
• Hand-rolled
• Interface based
• Anything goes

@gil_zilberfeld
Let’s play:
Where are the dependencies?

@gil_zilberfeld
Step 5: Simplify design
• Automatic refactoring
• Close down regions you’re not going to cover
• Rename fields
• Extract methods

• Manual refactoring works too
• …but more risky

@gil_zilberfeld
Step 6: Here we go!
• Arrange
Run
Fail
• Arrange
Run
Fail
…..
• Success!

@gil_zilberfeld
Step 7: Next!
• Pick the next
scenario
• Say it
• Name it
• Assert it

• Mutate the test
setup
• Arrange
Run
Fail
…
• Win!

@gil_zilberfeld
Congratulations!
• This is just the beginning
• Lifetime improvement
• Picking scenarios
• Naming
• Mocking
• Refactoring
• … and much more!

@gil_zilberfeld
Questions?
www.typemock.com

www.gilzilberfeld.com

typemock.com/blog

gilz@typemock.com

@typemock

@gil_zilberfeld

@gil_zilberfeld

Mais conteúdo relacionado

Destaque

App fabric hybrid computing
App fabric   hybrid computingApp fabric   hybrid computing
App fabric hybrid computing
Hammad Rajjoub
 
Azure Inside and Out
Azure Inside and OutAzure Inside and Out
Azure Inside and Out
Enrique Lima
 

Destaque (9)

App fabric introduction
App fabric introductionApp fabric introduction
App fabric introduction
 
App fabric hybrid computing
App fabric   hybrid computingApp fabric   hybrid computing
App fabric hybrid computing
 
Azure appfabric caching intro and tips
Azure appfabric caching intro and tipsAzure appfabric caching intro and tips
Azure appfabric caching intro and tips
 
Building An Application For Windows Azure And Sql Azure
Building An Application For Windows Azure And Sql AzureBuilding An Application For Windows Azure And Sql Azure
Building An Application For Windows Azure And Sql Azure
 
Windows Sql Azure Cloud Computing Platform
Windows Sql Azure Cloud Computing PlatformWindows Sql Azure Cloud Computing Platform
Windows Sql Azure Cloud Computing Platform
 
Introduction to Windows Azure AppFabric Applications
Introduction to Windows Azure AppFabric ApplicationsIntroduction to Windows Azure AppFabric Applications
Introduction to Windows Azure AppFabric Applications
 
Azure Inside and Out
Azure Inside and OutAzure Inside and Out
Azure Inside and Out
 
Jornada de Trabajo en la aldea Tekoa Miní - 06/06/2013
Jornada de Trabajo en la aldea Tekoa Miní - 06/06/2013Jornada de Trabajo en la aldea Tekoa Miní - 06/06/2013
Jornada de Trabajo en la aldea Tekoa Miní - 06/06/2013
 
The impact of cloud NSBCon NY by Yves Goeleven
The impact of cloud NSBCon NY by Yves GoelevenThe impact of cloud NSBCon NY by Yves Goeleven
The impact of cloud NSBCon NY by Yves Goeleven
 

Semelhante a Unit testing the prequel

An Introduction to Agile User Research and Testing #MW2015
An Introduction to Agile User Research and Testing #MW2015An Introduction to Agile User Research and Testing #MW2015
An Introduction to Agile User Research and Testing #MW2015
Liz Filardi
 

Semelhante a Unit testing the prequel (20)

Testing economics101
Testing economics101Testing economics101
Testing economics101
 
Zen and the Art of Test Maintenance
Zen and the Art of Test MaintenanceZen and the Art of Test Maintenance
Zen and the Art of Test Maintenance
 
Introduction to Unit Testing
Introduction to Unit TestingIntroduction to Unit Testing
Introduction to Unit Testing
 
Janet Gregory - Agile testing challenges Knowit 2014
Janet Gregory - Agile testing challenges Knowit 2014Janet Gregory - Agile testing challenges Knowit 2014
Janet Gregory - Agile testing challenges Knowit 2014
 
Real Life Test Maintenance
Real Life Test MaintenanceReal Life Test Maintenance
Real Life Test Maintenance
 
TDD for the rest of us...
TDD for the rest of us...TDD for the rest of us...
TDD for the rest of us...
 
Spaceship TDD Style
Spaceship TDD StyleSpaceship TDD Style
Spaceship TDD Style
 
Creating A Unit Testing Strategy
Creating A Unit Testing StrategyCreating A Unit Testing Strategy
Creating A Unit Testing Strategy
 
Introduction to TDD
Introduction to TDDIntroduction to TDD
Introduction to TDD
 
An Introduction to Agile User Research and Testing #MW2015
An Introduction to Agile User Research and Testing #MW2015An Introduction to Agile User Research and Testing #MW2015
An Introduction to Agile User Research and Testing #MW2015
 
TDD for Testers
TDD for TestersTDD for Testers
TDD for Testers
 
Claudiu Draghia ITEM 2018
Claudiu Draghia ITEM 2018Claudiu Draghia ITEM 2018
Claudiu Draghia ITEM 2018
 
Test Motherfucker...Test
Test Motherfucker...TestTest Motherfucker...Test
Test Motherfucker...Test
 
Continuous Learning - The New ALM
Continuous Learning - The New ALMContinuous Learning - The New ALM
Continuous Learning - The New ALM
 
Zen And the Art of Test Maintenance Presentation
Zen And the Art of Test Maintenance PresentationZen And the Art of Test Maintenance Presentation
Zen And the Art of Test Maintenance Presentation
 
10 Secret Unit Testing Tips
10 Secret Unit Testing Tips10 Secret Unit Testing Tips
10 Secret Unit Testing Tips
 
Zen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
Zen and the art of Test Maintenance - #TestIL Meetup Tel AvivZen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
Zen and the art of Test Maintenance - #TestIL Meetup Tel Aviv
 
TDD For The Rest Of Us
TDD For The Rest Of UsTDD For The Rest Of Us
TDD For The Rest Of Us
 
The fastest BDD crash-course ever
The fastest BDD crash-course everThe fastest BDD crash-course ever
The fastest BDD crash-course ever
 
Learn Learning + Prototype Testing
Learn Learning + Prototype TestingLearn Learning + Prototype Testing
Learn Learning + Prototype Testing
 

Mais de Gil Zilberfeld

Mais de Gil Zilberfeld (20)

Dirty tests and How To Clean Them
Dirty tests and How To Clean ThemDirty tests and How To Clean Them
Dirty tests and How To Clean Them
 
Unit testing for Grown-ups
Unit testing for Grown-upsUnit testing for Grown-ups
Unit testing for Grown-ups
 
Spock: It's Only Logical
Spock: It's Only LogicalSpock: It's Only Logical
Spock: It's Only Logical
 
Better Estimation and Planning
Better Estimation and PlanningBetter Estimation and Planning
Better Estimation and Planning
 
Dependency injection and Why It Matters to Testers
Dependency injection and Why It Matters to TestersDependency injection and Why It Matters to Testers
Dependency injection and Why It Matters to Testers
 
Spring Testing Features
Spring Testing FeaturesSpring Testing Features
Spring Testing Features
 
Better Estimation and Planning
Better Estimation and PlanningBetter Estimation and Planning
Better Estimation and Planning
 
The Untold User Story
The Untold User StoryThe Untold User Story
The Untold User Story
 
The Whole Story - Mapping, Slicing and Figuring things out
The Whole Story - Mapping, Slicing and Figuring things outThe Whole Story - Mapping, Slicing and Figuring things out
The Whole Story - Mapping, Slicing and Figuring things out
 
Fractal test planning
Fractal test planningFractal test planning
Fractal test planning
 
Agile Intro to DevOps
Agile Intro to DevOpsAgile Intro to DevOps
Agile Intro to DevOps
 
Playing games remotely
Playing games remotelyPlaying games remotely
Playing games remotely
 
A Horror Story
A Horror StoryA Horror Story
A Horror Story
 
An agile introduction to DevOps
An agile introduction to DevOpsAn agile introduction to DevOps
An agile introduction to DevOps
 
Why TDD is Important for Everyone
Why TDD is Important for EveryoneWhy TDD is Important for Everyone
Why TDD is Important for Everyone
 
Work
WorkWork
Work
 
Introduction to BDD
Introduction to BDDIntroduction to BDD
Introduction to BDD
 
Interview with the Vampire
Interview with the VampireInterview with the Vampire
Interview with the Vampire
 
TDD for the rest of us
TDD for the rest of usTDD for the rest of us
TDD for the rest of us
 
Simple
SimpleSimple
Simple
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
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
 
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, ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
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
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.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
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

Unit testing the prequel