TDD y BDD? ¿Cuál, por qué y cómo? [cerrado]
Frecuentes
Visto 308 veces
1 Respuestas
1
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.
public void Test()
{
// Arrange.
var sut = new ClassToTest();
// Act.
int result = sut.SoSomething();
// Assert.
Assert.Equal(result, 23);
}
With BDD (depending on the tools you're using) you tend to see something like this:
Feature: Add a user
As a system admin
In order to give a user access to the site
I want to create a user account
Scenario: Creating a basic user
Given I have the user's name
When I create a new user account
Then that user can log onto the site
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:
- NUNit
- xUnidad
- Prueba MST
A lot of the above tools can installed via NuGet in Visual Studio, which is handy.
Respondido 28 ago 12, 10:08
Thanks Jason, that was nice and sweet explanation to start with, but still I will look for a big dig as I want to go in depth of Which, Why and What. Cheers. - PuntoNetGeek
Regarding the "What" part of your question, we need to know what platform and programming language you intend to use e.g. Windows/Linux/Mac? .NET, Ruby on Rails, etc? - Jason Evans
Sorry for typo Jason, it was How and not What. I was thinking something else while typing. FYI, I am using .Net over Windows platform. thanks - PuntoNetGeek
Right, that was very helpful, I will explore more by visiting links you mentioned. Cheers. - PuntoNetGeek
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas tdd bdd or haz tu propia pregunta.
Article on topic: Los simulacros no son talones - oleksii
Your question should be reasonably scoped and specific. I'd try doing some research on the matter and if you need some clarifications, then ask them on SO. Also read the Preguntas Frecuentes on what consititutes a good question - Kibet Yegon
kibyegn, I know its not well scoped but what I am asking here is a strong evidence on both, so that I can understand it well. I will keep your suggestion in mind for next time, and wait for the outcome of your research. Thanks though. - DotNetGeek
Voting to close - since a complete answer to your broad question would need pages and wouldn't fit in the SO QnA format. Also this is slightly a subjective question... depending on the poster and the context of the project. - Gishu