TDD & BDD? Which, Why and How?
Can anyone give a good explanation to justify “Which”, “Why” and “How” on both?
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
TDD is used more for unit testing e.g. testing a method on a class. BDD is used for testing the behaviour of a system e.g. Creating a user, or Sending out new product emails.
So for TDD you might see something like.
With BDD (depending on the tools you’re using) you tend to see something like this:
As you can, BDD is testing the behaviour of a system rather then single unit. Here is a very good intro to BDD by Dan North – http://dannorth.net/introducing-bdd/
I would recommend using TDD when you are building your classes/code and want to testing little bits of it at a time. Use BDD when you want to test more then one of those classes in a test i.e. integration test.
EDIT:
With the how side of things, for BDD I would recommend using SpecFlow. This is a popular BDD tool which adds a lot of functionality to Visual Studio for creating feature files (The Feature: stuff I mentioned above) and running and debugging the tests.
Under the hood SpecFlow can use NUnit or MSTest to generate the tests. Other BDD tools include:
and many others I’ve forgotten about right now 🙂 I would suggest you try them out and see which one you prefer.
For TDD you have many options including:
A lot of the above tools can installed via NuGet in Visual Studio, which is handy.