Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can BDD be done "after"?

Tags:

tdd

testing

bdd

Unit testing is a practice of writing code tests. TDD is the practice of writing them "before". BDD is the practice of writing behavior/spec driven tests. Can I write BDD "after" or do I have to do it always "before"?

If you write BDD "after", and it's not BDD, then what it is called?

like image 359
Tower Avatar asked Apr 20 '12 06:04

Tower


People also ask

When should you not use BDD?

Disadvantages of BDD The primary “disadvantages” of BDD are two-fold. Because communications between the user and the developer are essential, if the user if not available, it will be difficult to work past ambiguities and questions generated by the user stories.

Can we do BDD without cucumber?

Cucumber without BDD might be a band-aid fix If we use cucumber just to have a file we can actually understand as developers, it is a sign for an unsolved problem. The true benefits of frameworks such as cucumber get visible, if any business experts are at least interacting with the examples.

What are the challenges in BDD framework?

BDD tools struggle with parallelization Tools such as Cucumber and SpecFlow do parallelization in a sub-optimal manner. They parallelize at the feature file level. This implies that if you want to run 50 tests in parallel, you need to have 50 feature files. That's a lot of feature files.

Is BDD good for automation?

BDD transpires from the TDD i.e. Test Driven Development which allows the users to work with multiple test data with minimum intervention in the software code and thereby helps to increase the reusability of the code, which is a time-saving mechanism in software development/ test automation.


2 Answers

By definition of Behaviour Driven Development, you cannot write the behaviour tests after the code, however that does not mean that doing so isn't useful. You may get more benefit from writing the spec tests first, but they are still useful as regression system tests for your application. So while you're technically not practicing BDD, writing these tests is a good idea. One of the big perks of BDD is that it guides the development of the particular behaviour, so you are losing a lot of value by adding them later, but they still serve some use.

This is the same as writing unit tests after the code in TDD. It's technically not TDD, but having the tests is obviously still useful.

like image 116
Oleksi Avatar answered Sep 29 '22 00:09

Oleksi


Behavior-Driven Development (BDD) is a variation of Test-Driven Development (TDD) and just like with TDD you should write your tests first.

Some people call BDD for TDD done right, or the way it was intended. Also, you could say that BDD is a mix of Domain-Driven Development (DDD) and TDD.

like image 41
Torbjörn Kalin Avatar answered Sep 29 '22 02:09

Torbjörn Kalin