SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
TDD Workshop
By Gopal Shah
Agenda
● Self Coding session – 45m
● Introduction to TDD – 15m
● TDD Group coding session – Part1 – 45m
● Break – 10m
● TDD Group coding session - Part2 – 45m
● TDD best practices & solution analysis – 30m
● Q & A – 20m
What is the workshop about?
Why TDD?
Should I write unit test for getter/setter?
When should I use mock library?
How do I write tests for static methods?
The problem is complex, where do I start?
I have a tight deadline … can I write tests later?
Is 100% test coverage a myth?
Break for coding session
Agile
● Individuals and interactions over Processes and
tools
● Working software over Comprehensive
documentation
● Customer collaboration over Contract
negotiation
● Responding to change over Following a plan
TDD
Refactoring
● Code refactoring is a "disciplined technique for restructuring
an existing body of code, altering its internal structure
without changing its external behavior",[1]
● undertaken in order to improve some of the nonfunctional
attributes of the software.
● Advantages include improved code readability and reduced
complexity to improve the maintainability of the source code,
● as well as a more expressive internal architecture or object
model to improve extensibility.
Red bar patterns
● One step test
● Starter test
● Explanation test
● Regression test
● Do over
Green bar patterns
● Isolated tests
● Fake it
● Triangulate
● Obvious implementation
Smells for bad tests
● Long setup code
● Setup duplication
● Long running tests
● Fragile tests
When should you delete tests?
● Confidence
● Communication
What have we learned?
Why TDD?
Should I write unit test for getter/setter?
When should I use mock library?
How do I write tests for static methods?
The problem is complex, where do I start?
I have a tight deadline … can I write tests later?
Is 100% test coverage a myth?
How Does TDD Relate To
Patterns?
“Another relationship between TDD and patterns is TDD as
an implementation method for pattern-driven design. Say we
decide we want a Strategy for something. We write a test for
the first variant and implement it as a method. Then we
consciously write a test for the second variant, expecting the
refactoring phase to drive us to a Strategy. Robert Martin and
I did some research into this style of TDD. The problem is the
design keeps surprising you. Perfectly sensible design ideas
turn out to be wrong. Better to just think about what you want
the system to do, and let the design sort itself out later”
- Kent Beck
Few links
● http://martinfowler.com/bliki/ComposedRegex.h
tml
● http://blog.flimflan.com/ReadableRegularExpres
sions.html
● http://martinfowler.com/articles/mocksArentStub
s.html

Mais conteúdo relacionado

Destaque

Anna Evaluation Question 1 Final
Anna Evaluation Question 1 FinalAnna Evaluation Question 1 Final
Anna Evaluation Question 1 Final
salesian2014as
 

Destaque (8)

Anna Evaluation Question 1 Final
Anna Evaluation Question 1 FinalAnna Evaluation Question 1 Final
Anna Evaluation Question 1 Final
 
12 Business Rules By Mark Cuban
12 Business Rules By Mark Cuban 12 Business Rules By Mark Cuban
12 Business Rules By Mark Cuban
 
Photographs of the Great Depression
Photographs of the Great DepressionPhotographs of the Great Depression
Photographs of the Great Depression
 
Weaving
WeavingWeaving
Weaving
 
Heterogeneity in adhd
Heterogeneity in adhdHeterogeneity in adhd
Heterogeneity in adhd
 
PHP & mySQL Training in Bangalore at myTectra
PHP & mySQL Training in Bangalore at myTectraPHP & mySQL Training in Bangalore at myTectra
PHP & mySQL Training in Bangalore at myTectra
 
Qlikview Training in Bangalore by myTectra
Qlikview Training in Bangalore by myTectraQlikview Training in Bangalore by myTectra
Qlikview Training in Bangalore by myTectra
 
GRID Signage: Future of Digital Signage
GRID Signage: Future of Digital SignageGRID Signage: Future of Digital Signage
GRID Signage: Future of Digital Signage
 

Último

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
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Último (20)

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
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 🔝✔️✔️
 
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...
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
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
 
+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...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
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
 

AmdJavaMeetupTDDWorkshop

  • 2. Agenda ● Self Coding session – 45m ● Introduction to TDD – 15m ● TDD Group coding session – Part1 – 45m ● Break – 10m ● TDD Group coding session - Part2 – 45m ● TDD best practices & solution analysis – 30m ● Q & A – 20m
  • 3. What is the workshop about? Why TDD? Should I write unit test for getter/setter? When should I use mock library? How do I write tests for static methods? The problem is complex, where do I start? I have a tight deadline … can I write tests later? Is 100% test coverage a myth?
  • 5. Agile ● Individuals and interactions over Processes and tools ● Working software over Comprehensive documentation ● Customer collaboration over Contract negotiation ● Responding to change over Following a plan
  • 6. TDD
  • 7. Refactoring ● Code refactoring is a "disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior",[1] ● undertaken in order to improve some of the nonfunctional attributes of the software. ● Advantages include improved code readability and reduced complexity to improve the maintainability of the source code, ● as well as a more expressive internal architecture or object model to improve extensibility.
  • 8. Red bar patterns ● One step test ● Starter test ● Explanation test ● Regression test ● Do over
  • 9. Green bar patterns ● Isolated tests ● Fake it ● Triangulate ● Obvious implementation
  • 10. Smells for bad tests ● Long setup code ● Setup duplication ● Long running tests ● Fragile tests
  • 11. When should you delete tests? ● Confidence ● Communication
  • 12. What have we learned? Why TDD? Should I write unit test for getter/setter? When should I use mock library? How do I write tests for static methods? The problem is complex, where do I start? I have a tight deadline … can I write tests later? Is 100% test coverage a myth?
  • 13. How Does TDD Relate To Patterns? “Another relationship between TDD and patterns is TDD as an implementation method for pattern-driven design. Say we decide we want a Strategy for something. We write a test for the first variant and implement it as a method. Then we consciously write a test for the second variant, expecting the refactoring phase to drive us to a Strategy. Robert Martin and I did some research into this style of TDD. The problem is the design keeps surprising you. Perfectly sensible design ideas turn out to be wrong. Better to just think about what you want the system to do, and let the design sort itself out later” - Kent Beck
  • 14. Few links ● http://martinfowler.com/bliki/ComposedRegex.h tml ● http://blog.flimflan.com/ReadableRegularExpres sions.html ● http://martinfowler.com/articles/mocksArentStub s.html