Test-Driven
Development
By: Ny Fanilo Andrianjafy
Demo: Romain Rocès
What I am going to talk about
● What is TDD ?
● Tests clarity and readability
● Mocks
● Behavior-Driven Development
● The goals
2
Source: http://blogs.msdn.com/b/seliot/archive/2011/04/25/i-don-t-always-test-my-code-but-when-i-do-i-do-it-in-production.aspx 3
What is Test-Driven Development
Lifecycle whose capital concept is:
Writing just enough code to satisfy specific conditions and continuously
refactoring the code afterward.
Repetition of very short development cycles.
Everything starts with a red sign.
4
It helps you to think
Requirements are likely to be separated in small testable pieces of code.
You know how to use your code before writing it.
Edge cases can be discovered before anything is deployed.
5
Source: https://github.com/mjhea0/flaskr-tdd
6
Clarity and
readability
7
Setup and Teardown
Setup and clean up the test environment for the object you are testing.
Keep it clear and simple.
Complicated setup is a good sign of poor tests organization and design..
If tests actually need complicated setup, decouple them from the tests. (e.g. Shared file)
8
Setup and Tear Down
Source: http://www.slideshare.net/fitc_slideshare/the-little-shop-of-tdd-horrors-53208388
9
Tests coverage
Not testing 100% of your code lines does not makes you a bad person.
Using the above sentence to your advantage to write very few tests and
eventually omit the fundamental of your code makes you a bad person.
Not all conditions/paths are tested.
10
Tests are code
Treat your tests well.
Keep them readable.
Never write tests that nobody wants or is able to read. You may have to re-read them someday.
The good practice you have in mind when writing production code should also
be on your mind when writing the tests.
Do not let them become garbage.
11
Clarity
The clarity of expectations is golden for others.
Naming your tests is important, do not worry about the length.
Write good descriptions.
Be lazy. Anybody should be able to look at the test and understand.
Arrange, Act, Assert. (AAA) Separate them. Space your code.
12
You will not write nice code on first try
TDD is a lifecycle, the last step is refactoring
Refactor only on green. Not before, satisfy the tests first.
You will have multiple iterations of refactor, sometimes small, sometimes a tad
bigger.
One advice: time box
Example: 30 minute lifecycle (or what pleases you)
10 minutes of writing tests
10 minutes of writing code
13
Mocks
14
Network Responses
You might need to have tests that checks the sanity of external API’s
Be clear about your expectations.
Tests are code: do not ignore the performance issues and bottlenecks.
It is a good idea to create a separate environment for tests that really go to the
server.
15
Mock
When mocking data: mock only what you need. Do not load an entire Model for
nothing.
16
Behavior
17
Behavior
Focus on testing software behaviors rather that single unit of code.
Group tests and behaviors that are tied together.
Connect similar behavior using keywords like with/when/given.
Be aware of complexity
Being unable to organize tests easily might be caused by confusing requirements.
The key is: Scenarios => Use Cases => Behaviors
18
Goals
19
Goals
Profitable: The tests should be profitable. It should give you a value
Maintainability: It helps your software to be maintainable
Common understanding
Validate the understanding of behaviors
Quality
20

More Related Content

PPTX
The problem with tdd
ODP
TDD - Test Driven Development
PDF
Tdd practices
PPTX
TDD with RSpec
KEY
TDD refresher
The problem with tdd
TDD - Test Driven Development
Tdd practices
TDD with RSpec
TDD refresher

What's hot (20)

PPTX
TDD = bra design?
PPTX
Test driven development(tdd)
PDF
TDD for the masses
PDF
Test driven development - Zombie proof your code
PDF
Test driven development vs Behavior driven development
PPTX
클린 테스트
PPTX
Tdd com Java
PDF
TDD CrashCourse Part2: TDD
PPT
Test drive on driven development process
PPTX
Test Driven Development
PDF
16 things a developer should know about testing
PPTX
Best pratice
PDF
Tdd 왜 배우기 어려운가
PDF
Introduction to TDD (Test Driven development) - Ahmed Shreef
PPT
Introducing bdd elements to unit testing.pptx
PDF
Test Driven Development
PDF
Why and how to keep your code quality
KEY
Test Driven Development
ODP
Tdd in php a brief example
PDF
Bdd - L'arte di non farsi i fatti propri
TDD = bra design?
Test driven development(tdd)
TDD for the masses
Test driven development - Zombie proof your code
Test driven development vs Behavior driven development
클린 테스트
Tdd com Java
TDD CrashCourse Part2: TDD
Test drive on driven development process
Test Driven Development
16 things a developer should know about testing
Best pratice
Tdd 왜 배우기 어려운가
Introduction to TDD (Test Driven development) - Ahmed Shreef
Introducing bdd elements to unit testing.pptx
Test Driven Development
Why and how to keep your code quality
Test Driven Development
Tdd in php a brief example
Bdd - L'arte di non farsi i fatti propri
Ad

Similar to Test-Driven Development (20)

PPTX
{10.0} Test Driven Development.pptx
PDF
Test-Driven Development
PPTX
Test Driven Development
PDF
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
PPTX
Test driven development
PPTX
A Brief Introduction to Test-Driven Development
PPTX
Test-Driven Development
PDF
Test Driven Development
PPTX
Is your code ready for testing?
PPTX
TDD - Seriously, try it - Codemotion (May '24)
PDF
Test Driven Development SpeedRun
PPTX
Intro to TDD
PPTX
TDD - Seriously, try it! - Opensouthcode
KEY
Getting Comfortable with BDD
PDF
Test driven development
PPTX
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
PPTX
Test Driven Development
PPTX
Prashant technical practices-tdd for xebia event
PPTX
Test Policy and Practices
{10.0} Test Driven Development.pptx
Test-Driven Development
Test Driven Development
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test driven development
A Brief Introduction to Test-Driven Development
Test-Driven Development
Test Driven Development
Is your code ready for testing?
TDD - Seriously, try it - Codemotion (May '24)
Test Driven Development SpeedRun
Intro to TDD
TDD - Seriously, try it! - Opensouthcode
Getting Comfortable with BDD
Test driven development
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Test Driven Development
Prashant technical practices-tdd for xebia event
Test Policy and Practices
Ad

Recently uploaded (20)

PDF
Time Tracking Features That Teams and Organizations Actually Need
PDF
MCP Security Tutorial - Beginner to Advanced
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
CNN LeNet5 Architecture: Neural Networks
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PPTX
GSA Content Generator Crack (2025 Latest)
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
Visual explanation of Dijkstra's Algorithm using Python
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
PPTX
Introduction to Windows Operating System
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PDF
Website Design Services for Small Businesses.pdf
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PDF
Topaz Photo AI Crack New Download (Latest 2025)
Time Tracking Features That Teams and Organizations Actually Need
MCP Security Tutorial - Beginner to Advanced
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
CNN LeNet5 Architecture: Neural Networks
Advanced SystemCare Ultimate Crack + Portable (2025)
GSA Content Generator Crack (2025 Latest)
Weekly report ppt - harsh dattuprasad patel.pptx
iTop VPN Crack Latest Version Full Key 2025
Visual explanation of Dijkstra's Algorithm using Python
Salesforce Agentforce AI Implementation.pdf
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
Introduction to Windows Operating System
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
Computer Software and OS of computer science of grade 11.pptx
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
Website Design Services for Small Businesses.pdf
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
DNT Brochure 2025 – ISV Solutions @ D365
Topaz Photo AI Crack New Download (Latest 2025)

Test-Driven Development

  • 1. Test-Driven Development By: Ny Fanilo Andrianjafy Demo: Romain Rocès
  • 2. What I am going to talk about ● What is TDD ? ● Tests clarity and readability ● Mocks ● Behavior-Driven Development ● The goals 2
  • 4. What is Test-Driven Development Lifecycle whose capital concept is: Writing just enough code to satisfy specific conditions and continuously refactoring the code afterward. Repetition of very short development cycles. Everything starts with a red sign. 4
  • 5. It helps you to think Requirements are likely to be separated in small testable pieces of code. You know how to use your code before writing it. Edge cases can be discovered before anything is deployed. 5
  • 8. Setup and Teardown Setup and clean up the test environment for the object you are testing. Keep it clear and simple. Complicated setup is a good sign of poor tests organization and design.. If tests actually need complicated setup, decouple them from the tests. (e.g. Shared file) 8
  • 9. Setup and Tear Down Source: http://www.slideshare.net/fitc_slideshare/the-little-shop-of-tdd-horrors-53208388 9
  • 10. Tests coverage Not testing 100% of your code lines does not makes you a bad person. Using the above sentence to your advantage to write very few tests and eventually omit the fundamental of your code makes you a bad person. Not all conditions/paths are tested. 10
  • 11. Tests are code Treat your tests well. Keep them readable. Never write tests that nobody wants or is able to read. You may have to re-read them someday. The good practice you have in mind when writing production code should also be on your mind when writing the tests. Do not let them become garbage. 11
  • 12. Clarity The clarity of expectations is golden for others. Naming your tests is important, do not worry about the length. Write good descriptions. Be lazy. Anybody should be able to look at the test and understand. Arrange, Act, Assert. (AAA) Separate them. Space your code. 12
  • 13. You will not write nice code on first try TDD is a lifecycle, the last step is refactoring Refactor only on green. Not before, satisfy the tests first. You will have multiple iterations of refactor, sometimes small, sometimes a tad bigger. One advice: time box Example: 30 minute lifecycle (or what pleases you) 10 minutes of writing tests 10 minutes of writing code 13
  • 15. Network Responses You might need to have tests that checks the sanity of external API’s Be clear about your expectations. Tests are code: do not ignore the performance issues and bottlenecks. It is a good idea to create a separate environment for tests that really go to the server. 15
  • 16. Mock When mocking data: mock only what you need. Do not load an entire Model for nothing. 16
  • 18. Behavior Focus on testing software behaviors rather that single unit of code. Group tests and behaviors that are tied together. Connect similar behavior using keywords like with/when/given. Be aware of complexity Being unable to organize tests easily might be caused by confusing requirements. The key is: Scenarios => Use Cases => Behaviors 18
  • 20. Goals Profitable: The tests should be profitable. It should give you a value Maintainability: It helps your software to be maintainable Common understanding Validate the understanding of behaviors Quality 20