Test Driven Development
Test Driven Development
"Test-driven development" refers to a style of programming in which three
activities are tightly interwoven: coding, testing (in the form of writing unit tests)
and design (in the form of refactoring).
Unit Testing
A software test is a piece of software, which executes another piece of software.
Verify that your code is running correctly
Provide documentation of code
Catch future errors
Long-term savings
Clean Unit Tests
Test method name should be presented as a statement or fact of life that
expresses workflows and outputs
All test methods may be executed in an arbitrary order.
Test cases should be fast
Test code should be as clean and modular as regular code
The TDD Cycle
Define what the code will do
Write a test that will pass if the code does that
thing
Run the test, see it fail
Write the code
Run the test, see it pass
Refactor
Let’s try it
Create a simple String calculator with a method int Add(string numbers). 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”
Allow the Add method to handle an unknown amount of numbers
Allow the Add method to handle new lines between numbers (instead of commas).
The following input is ok: “1n2,3” (will equal 6)
Support different delimiters
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 ‘;’ .
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

More Related Content

PDF
selection structures
PDF
OOPS With CSharp - Jinal Desai .NET
PPTX
Introduction to TDD
PPTX
Moneeba Anwar
PDF
Intake 37 2
PPT
evaluating recursive_applications
PDF
Maxbox starter
PPT
recursive problem_solving
selection structures
OOPS With CSharp - Jinal Desai .NET
Introduction to TDD
Moneeba Anwar
Intake 37 2
evaluating recursive_applications
Maxbox starter
recursive problem_solving

What's hot (20)

PPTX
Operators used in vb.net
PPTX
FUNDAMENTAL OF C
PDF
Still Comparing "this" Pointer to Null?
PDF
Intake 37 1
PDF
Functions
PPTX
Python Lecture 2
PPTX
Python Training in Bangalore | Python Introduction Session | Learnbay
PPTX
Pj01 3-java-variable and data types
PPT
composing procedures
PPTX
Handling inputs via scanner class
PPT
Md04 flow control
DOCX
Experiment 9(exceptions)
PPTX
Loop control statements
DOC
Learn VbScript -String Functions
PPTX
if, while and for in Python
PPTX
Operating system
PPTX
Introduction To Programming with Python Lecture 2
PDF
Presentation
PDF
Chapter 3
Operators used in vb.net
FUNDAMENTAL OF C
Still Comparing "this" Pointer to Null?
Intake 37 1
Functions
Python Lecture 2
Python Training in Bangalore | Python Introduction Session | Learnbay
Pj01 3-java-variable and data types
composing procedures
Handling inputs via scanner class
Md04 flow control
Experiment 9(exceptions)
Loop control statements
Learn VbScript -String Functions
if, while and for in Python
Operating system
Introduction To Programming with Python Lecture 2
Presentation
Chapter 3
Ad

Similar to Test driven development (20)

PPTX
SWE-6 TESTING.pptx
DOCX
Java execise
PPTX
Automation Testing theory notes.pptx
PPTX
DOC-20240812-WA0000 array string and.pptx
PPT
js sdfsdfsdfsdfsdfsdfasdfsdfsdfsdaaray.ppt
PPTX
SE2018_Lec 20_ Test-Driven Development (TDD)
PPTX
Lecture 7
PPSX
Algorithms, Structure Charts, Corrective and adaptive.ppsx
PPTX
Python Basics
PDF
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
PPTX
VISUAL BASIC 6 - CONTROLS AND DECLARATIONS
PPT
Chapter2pp
PPTX
Java-Programming.forBSITSTUDENTfreespptx
PPT
Lecture 01-2.ppt
PPTX
Algorithm & data structure lec2
DOCX
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
PPTX
Tdd guide
PPT
467719275-Lecture-01 designe and alg.ppt
PPT
RPG Program for Unit Testing RPG
PPT
Test Driven Development
SWE-6 TESTING.pptx
Java execise
Automation Testing theory notes.pptx
DOC-20240812-WA0000 array string and.pptx
js sdfsdfsdfsdfsdfsdfasdfsdfsdfsdaaray.ppt
SE2018_Lec 20_ Test-Driven Development (TDD)
Lecture 7
Algorithms, Structure Charts, Corrective and adaptive.ppsx
Python Basics
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
VISUAL BASIC 6 - CONTROLS AND DECLARATIONS
Chapter2pp
Java-Programming.forBSITSTUDENTfreespptx
Lecture 01-2.ppt
Algorithm & data structure lec2
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
Tdd guide
467719275-Lecture-01 designe and alg.ppt
RPG Program for Unit Testing RPG
Test Driven Development
Ad

Recently uploaded (20)

PPTX
Tech Workshop Escape Room Tech Workshop
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PDF
MCP Security Tutorial - Beginner to Advanced
PPTX
assetexplorer- product-overview - presentation
PPTX
Introduction to Windows Operating System
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PDF
CCleaner 6.39.11548 Crack 2025 License Key
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
Visual explanation of Dijkstra's Algorithm using Python
PDF
Website Design Services for Small Businesses.pdf
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PPTX
Trending Python Topics for Data Visualization in 2025
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PPTX
"Secure File Sharing Solutions on AWS".pptx
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
Tech Workshop Escape Room Tech Workshop
Wondershare Recoverit Full Crack New Version (Latest 2025)
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
MCP Security Tutorial - Beginner to Advanced
assetexplorer- product-overview - presentation
Introduction to Windows Operating System
iTop VPN Crack Latest Version Full Key 2025
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
DNT Brochure 2025 – ISV Solutions @ D365
CCleaner 6.39.11548 Crack 2025 License Key
Why Generative AI is the Future of Content, Code & Creativity?
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Visual explanation of Dijkstra's Algorithm using Python
Website Design Services for Small Businesses.pdf
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Trending Python Topics for Data Visualization in 2025
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
"Secure File Sharing Solutions on AWS".pptx
Weekly report ppt - harsh dattuprasad patel.pptx

Test driven development

  • 2. Test Driven Development "Test-driven development" refers to a style of programming in which three activities are tightly interwoven: coding, testing (in the form of writing unit tests) and design (in the form of refactoring).
  • 3. Unit Testing A software test is a piece of software, which executes another piece of software. Verify that your code is running correctly Provide documentation of code Catch future errors Long-term savings
  • 4. Clean Unit Tests Test method name should be presented as a statement or fact of life that expresses workflows and outputs All test methods may be executed in an arbitrary order. Test cases should be fast Test code should be as clean and modular as regular code
  • 5. The TDD Cycle Define what the code will do Write a test that will pass if the code does that thing Run the test, see it fail Write the code Run the test, see it pass Refactor
  • 6. Let’s try it Create a simple String calculator with a method int Add(string numbers). 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” Allow the Add method to handle an unknown amount of numbers Allow the Add method to handle new lines between numbers (instead of commas). The following input is ok: “1n2,3” (will equal 6) Support different delimiters 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 ‘;’ . 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