際際滷

際際滷Share a Scribd company logo
Women Who Can Code
Code Dojo : Basics of Test Driven Development
11th March 2015
Laavanya Kathiresen @Nintex
What is Code Dojo ?
Programmers gather to train & learn, working together on a problem (while having
fun!)
NOT a competition
2 types of ways of running it :
 Prepared Kata (with Baby Steps)
 Randori Kata
Test Driven Development (TDD)
Kent Beck - Father of TDD
Test First Programming Concept
Repetition of short development cycle
Red-Green-Refactoring
Having unit tests doesnt mean
youve done TDD
Why do TDD ?
Better code quality (less coupling)
Encourages simple design and concepts
Reduces the risk of over-engineering
Ability to refactor without fear of breaking anything
Improved maintainability and changeability of the codebase
& MANY MORE!!!!
Introduction to TDD
Prepared Kata :
String Calculator
Create a simple String calculator with a method int Add(string
numbers)
1. The method can take 0, 1 or 2 numbers, and will return their sum (for an empty string it will return 0) for
example  or 1 or 1,2
2. Start with the simplest test case of an empty string and move to 1 and two numbers
3. Remember to solve things as simply as possible so that you force yourself to write tests you did not think about
4. Remember to refactor after each passing test
Allow the Add method to handle an unknown amount of
numbers
Allow the Add method to handle new lines between numbers
(instead of commas).
1. the following input is ok: 1n2,3 (will equal 6)
2. the following input is NOT ok: 1,n (not need to prove it - just clarifying)
Support different delimiters
1. to change a delimiter, the beginning of the string will contain a separate
line that looks like this: //[delimiter]n[numbers] for example
//;n1;2 should return three where the default delimiter is ; .
2. the first line is optional. all existing scenarios should still be supported
Calling Add with a negative number will throw an exception
negatives not allowed - and the negative that was passed.
If there are multiple negatives, show all of them in the
exception message
Numbers bigger than 1000 should be ignored, so adding 2
+ 1001 = 2
Delimiters can be of any length with the following format:
//[delimiter]n for example: //[***]n1***2***3 should
return 6
Challenges in TDD..
Initially it might take longer than expected to do TDD
 hence might not get the support and encouragement from management
Developers tend to reverse-engineer unit test hence losing the benefit of TDD
TDD on legacy code can be challenging
Puts Thats it for now, thank you for
participatingn
Puts Please do give you feedback on what
youll to know more on
Allow multiple delimiters like this: //[delim1][delim2]n
Example //[*][%]n1*2%3 should return 6.
Ad

Recommended

Smu bsc it sem 2 fall 2014 solved assignments
Smu bsc it sem 2 fall 2014 solved assignments
smumbahelp
Jason Smith Format Preferences
Jason Smith Format Preferences
Tyler Murphy
Code sense
Code sense
nasirj
Smu mscit sem 3 fall 2014 assignments
Smu mscit sem 3 fall 2014 assignments
smumbahelp
online test system
online test system
M Junaid Akbar
Learn VbScript -String Functions
Learn VbScript -String Functions
Nilanjan Saha
Smu bca sem 2 fall 2014 solved assignments
Smu bca sem 2 fall 2014 solved assignments
smumbahelp
Fighting null with memes
Fighting null with memes
Jarek Ratajski
Test driven development
Test driven development
Xebia India
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
Pietro Di Bello
Tdd guide
Tdd guide
Hanokh Aloni
Test driven development (TDD)
Test driven development (TDD)
Tony Dillon-Hansen
TDD Walkthrough - Encryption
TDD Walkthrough - Encryption
PeterKha2
TDD a piccoli passi
TDD a piccoli passi
Ferdinando Santacroce
How to complement TDD with static analysis
How to complement TDD with static analysis
PVS-Studio
Scala 3 Is Coming: Martin Odersky Shares What To Know
Scala 3 Is Coming: Martin Odersky Shares What To Know
Lightbend
Lotusphere 2007 AD505 DevBlast 30 LotusScript Tips
Lotusphere 2007 AD505 DevBlast 30 LotusScript Tips
Bill Buchan
June 05 P2
June 05 P2
Samimvez
Acm aleppo cpc training second session
Acm aleppo cpc training second session
Ahmad Bashar Eter
An introduction to Competitive Programming
An introduction to Competitive Programming
Gaurav Agarwal
Anti-Patterns
Anti-Patterns
Robert Brown
TDD - Test Driven Development
TDD - Test Driven Development
Tung Nguyen Thanh
Visual basic intoduction
Visual basic intoduction
mohamedsaad24
Introduzione allo Unit Testing
Introduzione allo Unit Testing
Stefano Ottaviani
2CPP15 - Templates
2CPP15 - Templates
Michael Heron
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
Hawkman Academy
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
anhlodge
LECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdf
SHASHIKANT346021
Simplify Insurance Regulations with Compliance Management Software
Simplify Insurance Regulations with Compliance Management Software
Insurance Tech Services
Digital Transformation: Automating the Placement of Medical Interns
Digital Transformation: Automating the Placement of Medical Interns
Safe Software

More Related Content

Similar to Introduction to TDD (20)

Test driven development
Test driven development
Xebia India
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
Pietro Di Bello
Tdd guide
Tdd guide
Hanokh Aloni
Test driven development (TDD)
Test driven development (TDD)
Tony Dillon-Hansen
TDD Walkthrough - Encryption
TDD Walkthrough - Encryption
PeterKha2
TDD a piccoli passi
TDD a piccoli passi
Ferdinando Santacroce
How to complement TDD with static analysis
How to complement TDD with static analysis
PVS-Studio
Scala 3 Is Coming: Martin Odersky Shares What To Know
Scala 3 Is Coming: Martin Odersky Shares What To Know
Lightbend
Lotusphere 2007 AD505 DevBlast 30 LotusScript Tips
Lotusphere 2007 AD505 DevBlast 30 LotusScript Tips
Bill Buchan
June 05 P2
June 05 P2
Samimvez
Acm aleppo cpc training second session
Acm aleppo cpc training second session
Ahmad Bashar Eter
An introduction to Competitive Programming
An introduction to Competitive Programming
Gaurav Agarwal
Anti-Patterns
Anti-Patterns
Robert Brown
TDD - Test Driven Development
TDD - Test Driven Development
Tung Nguyen Thanh
Visual basic intoduction
Visual basic intoduction
mohamedsaad24
Introduzione allo Unit Testing
Introduzione allo Unit Testing
Stefano Ottaviani
2CPP15 - Templates
2CPP15 - Templates
Michael Heron
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
Hawkman Academy
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
anhlodge
LECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdf
SHASHIKANT346021
Test driven development
Test driven development
Xebia India
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
Pietro Di Bello
Test driven development (TDD)
Test driven development (TDD)
Tony Dillon-Hansen
TDD Walkthrough - Encryption
TDD Walkthrough - Encryption
PeterKha2
How to complement TDD with static analysis
How to complement TDD with static analysis
PVS-Studio
Scala 3 Is Coming: Martin Odersky Shares What To Know
Scala 3 Is Coming: Martin Odersky Shares What To Know
Lightbend
Lotusphere 2007 AD505 DevBlast 30 LotusScript Tips
Lotusphere 2007 AD505 DevBlast 30 LotusScript Tips
Bill Buchan
June 05 P2
June 05 P2
Samimvez
Acm aleppo cpc training second session
Acm aleppo cpc training second session
Ahmad Bashar Eter
An introduction to Competitive Programming
An introduction to Competitive Programming
Gaurav Agarwal
TDD - Test Driven Development
TDD - Test Driven Development
Tung Nguyen Thanh
Visual basic intoduction
Visual basic intoduction
mohamedsaad24
Introduzione allo Unit Testing
Introduzione allo Unit Testing
Stefano Ottaviani
2CPP15 - Templates
2CPP15 - Templates
Michael Heron
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
Hawkman Academy
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
anhlodge
LECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdf
SHASHIKANT346021

Recently uploaded (20)

Simplify Insurance Regulations with Compliance Management Software
Simplify Insurance Regulations with Compliance Management Software
Insurance Tech Services
Digital Transformation: Automating the Placement of Medical Interns
Digital Transformation: Automating the Placement of Medical Interns
Safe Software
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
AI for PV: Development and Governance for a Regulated Industry
AI for PV: Development and Governance for a Regulated Industry
Biologit
Simplify Task, Team, and Project Management with Orangescrum Work
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
How Automation in Claims Handling Streamlined Operations
How Automation in Claims Handling Streamlined Operations
Insurance Tech Services
Folding Cheat Sheet # 9 - List Unfolding as the Computational Dual of ...
Folding Cheat Sheet # 9 - List Unfolding as the Computational Dual of ...
Philip Schwarz
Introduction to Agile Frameworks for Product Managers.pdf
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
Why Edge Computing Matters in Mobile Application Tech.pdf
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
Zoho Creator Solution for EI by Elsner Technologies.docx
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
Humans vs AI Call Agents - Qcall.ai's Special Report
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
Which Hiring Management Tools Offer the Best ROI?
Which Hiring Management Tools Offer the Best ROI?
HireME
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
A Guide to Telemedicine Software Development.pdf
A Guide to Telemedicine Software Development.pdf
Olivero Bozzelli
Top Time Tracking Solutions for Accountants
Top Time Tracking Solutions for Accountants
oliviareed320
Simplify Insurance Regulations with Compliance Management Software
Simplify Insurance Regulations with Compliance Management Software
Insurance Tech Services
Digital Transformation: Automating the Placement of Medical Interns
Digital Transformation: Automating the Placement of Medical Interns
Safe Software
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
AI for PV: Development and Governance for a Regulated Industry
AI for PV: Development and Governance for a Regulated Industry
Biologit
Simplify Task, Team, and Project Management with Orangescrum Work
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
How Automation in Claims Handling Streamlined Operations
How Automation in Claims Handling Streamlined Operations
Insurance Tech Services
Folding Cheat Sheet # 9 - List Unfolding as the Computational Dual of ...
Folding Cheat Sheet # 9 - List Unfolding as the Computational Dual of ...
Philip Schwarz
Introduction to Agile Frameworks for Product Managers.pdf
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
Why Edge Computing Matters in Mobile Application Tech.pdf
Why Edge Computing Matters in Mobile Application Tech.pdf
IMG Global Infotech
Zoho Creator Solution for EI by Elsner Technologies.docx
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
Humans vs AI Call Agents - Qcall.ai's Special Report
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
Which Hiring Management Tools Offer the Best ROI?
Which Hiring Management Tools Offer the Best ROI?
HireME
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
A Guide to Telemedicine Software Development.pdf
A Guide to Telemedicine Software Development.pdf
Olivero Bozzelli
Top Time Tracking Solutions for Accountants
Top Time Tracking Solutions for Accountants
oliviareed320
Ad

Introduction to TDD

  • 1. Women Who Can Code Code Dojo : Basics of Test Driven Development 11th March 2015 Laavanya Kathiresen @Nintex
  • 2. What is Code Dojo ? Programmers gather to train & learn, working together on a problem (while having fun!) NOT a competition 2 types of ways of running it : Prepared Kata (with Baby Steps) Randori Kata
  • 3. Test Driven Development (TDD) Kent Beck - Father of TDD Test First Programming Concept Repetition of short development cycle Red-Green-Refactoring Having unit tests doesnt mean youve done TDD
  • 4. Why do TDD ? Better code quality (less coupling) Encourages simple design and concepts Reduces the risk of over-engineering Ability to refactor without fear of breaking anything Improved maintainability and changeability of the codebase & MANY MORE!!!!
  • 7. Create a simple String calculator with a method int Add(string numbers) 1. The method can take 0, 1 or 2 numbers, and will return their sum (for an empty string it will return 0) for example or 1 or 1,2 2. Start with the simplest test case of an empty string and move to 1 and two numbers 3. Remember to solve things as simply as possible so that you force yourself to write tests you did not think about 4. Remember to refactor after each passing test
  • 8. Allow the Add method to handle an unknown amount of numbers
  • 9. Allow the Add method to handle new lines between numbers (instead of commas). 1. the following input is ok: 1n2,3 (will equal 6) 2. the following input is NOT ok: 1,n (not need to prove it - just clarifying)
  • 10. Support different delimiters 1. to change a delimiter, the beginning of the string will contain a separate line that looks like this: //[delimiter]n[numbers] for example //;n1;2 should return three where the default delimiter is ; . 2. the first line is optional. all existing scenarios should still be supported
  • 11. Calling Add with a negative number will throw an exception negatives not allowed - and the negative that was passed. If there are multiple negatives, show all of them in the exception message
  • 12. Numbers bigger than 1000 should be ignored, so adding 2 + 1001 = 2
  • 13. Delimiters can be of any length with the following format: //[delimiter]n for example: //[***]n1***2***3 should return 6
  • 14. Challenges in TDD.. Initially it might take longer than expected to do TDD hence might not get the support and encouragement from management Developers tend to reverse-engineer unit test hence losing the benefit of TDD TDD on legacy code can be challenging
  • 15. Puts Thats it for now, thank you for participatingn Puts Please do give you feedback on what youll to know more on
  • 16. Allow multiple delimiters like this: //[delim1][delim2]n Example //[*][%]n1*2%3 should return 6.