2. Agenda
• What is TDD.
• Steps to follow.
• Advantages.
• Disadvantages.
• TDD vs BDD.
• Unit Test and Integration Test..!!.
3. What is TDD
• TDD is a software development methodology whereby you write
and run a set of Tests before you write code.
• Another definition : TDD is a software development process
that relies on the repetition of a very short development cycle.
• The idea is that those Tests will fail at first and then you start
to write enough code to try to get all the Tests to pass.
4. 5-STEPS
TDD uses Tests as way to design code
by creating an initially failing Test
before any actual production code is
written. You then try to make the Test
pass by creating production code that
fulfills the Test. This is usually five-
steps process:
• Write test
• Run the test and show that it fails.
• Write the smallest amount of
production code possible that meets
the needs of the test.
• Run the test until it pass.
• Refactor.
5. Advantages
• Modular Code.
• Good architecture.
• Documents your code better.
• Maintain and Refactor.
• Makes collaboration easier.
• Helps programmers really understand their code.
• It helps to clarify requirements
6. Disadvantages
• The test itself must be maintained.
• Hard to write.
• Challenge to learn.
• Unit testing is something the whole team has to buy into.
• It slows down development.
• Hard to apply to existing legacy code.
• Hard to start working this way.
• Early stage refactoring requires refactoring test classes as well.
• Unless everyone on the team correctly maintains their tests, the whole system can quickly
degrade.
7. BDD
• Behavior-Driven Development (BDD) is an agile process
designed to keep the focus on stakeholder throughout the
whole project.
• The premise of BDD is that the requirement has to be written in
a way that everyone understands it and use it.
• Every BDD Test consists of one or many features which has
narratives and scenarios.
8. BDD VS TDD
• Before we go to the comparison, we should understand that:
• When I test for behavior, I’m saying: “I don’t care how you come
up with the answer, just make sure that the answer is correct
under this set of conditions”
• When I test for implementation, I’m saying: “I don’t care what
the answer is, just make sure you do this task.”
9. BDD VS TDD
• White box testing: White box testing focuses on activities that
require you to know the underlying source code of a program
(TDD).
• Black box testing is the opposite. You act as if you have no idea
how the program should work (BDD).
10. BDD VS TDD
• BDD written in simple descriptive English.
• BDD written from perspective of Customer or Project
owner.
• BDD tests the behaviors that the application should
have.
• Tools: SpecFlow, etc.
• Can be understood by any person.
• Maybe better approach for projects which are driven by
user actions like ecommerce.
• Collaboration is required between all stakeholders.
• BDD scenarios are not much impacted by the
functionality changes.
• Describes how the end user uses the software.
• In TDD we writing code.
• TDD written from perspective of developer.
• TDD test the functionality of the application.
• Tools: Nunit, etc.
• Can only be understood by programmers.
• Maybe be better approach for projects which involve API
and third-party tool.
• Collaboration is required only between developers.
• Changes in how application functions impact a lot on
test cases.
• TDD describes how the software works.
11. Unit Test And Integration Test
• Unit Testing and Integration Test refers to what you are
testing, while TDD refers to when you are testing.
• Unit testing is testing the smallest single amount of code,
usually at a method level. A unit test shouldn't have any
dependencies on anything external.
• When you start combining two or more pieces of logic together,
it gets you into Integration Testing.