DEV Community

Cover image for Testing With TDD And BDD

Testing With TDD And BDD

Milecia on May 02, 2019

Testing is an un-skippable part of any development process (even if it does get skipped in practice). There are different methodologies you can use...
Collapse
 
sevillaarvin profile image
sevillaarvin

Hi, thank you for your post. The way I've always understood it is that, BDD is TDD done right. TDD tells us that we have to test our code before we develop. BDD tells us which code matters that warrants testing.

Collapse
 
mrlarson2007 profile image
Michael Larson

Great post. I am a big TDD proponent and have said the exact thing in the past to others! Also Dan North, the person who created BDD, said that was his intention. You will even see examples of people using the given/when/then format in their tests.

Collapse
 
mtnrbq profile image
mtnrbq

Hi, this is the clearest way I've come across of describing the right way of doing testing for client facing systems (IMHO :)). Thanks for this, and I'll definitely be pointing my team at it.

Collapse
 
mattzgg_94 profile image
Matthew Gong

Very helpful article. It enhanced my thought about BDD. BDD uses the test-first approach which is the core idea of TDD but the tests in BDD are business functionality oriented instead of code oriented.

Collapse
 
chimung profile image
chimung

"One advantage of writing tests this way is that you won't have to update the test implementation every time you update the code implementation." - I dont get that. Why we need update the test when the code implementation changes?
For example: Writing function which calculates Fibonacci.

In TDD: assert.equal(1, factorial(0));
In BDD: factorial(0).should.equal(1);

When we change the implementation, we dont need to update this test.
I only see the difference in syntax. Can you figure out with this example?