tdd-vs-bdd icon indicating copy to clipboard operation
tdd-vs-bdd copied to clipboard

BDD should be more abstract

Open ghost opened this issue 7 years ago • 0 comments

You can use multiple abstraction levels by BDD and higher levels are preferred compared to TDD. Your example uses the lowest possible level. A higher level example would be something like this:

describe('factorial(number)', function (){
      it('should return the factorial of the given number', function (){
            factorial(0).should.equal(1);
            factorial(1).should.equal(1);
            factorial(2).should.equal(2);
            factorial(3).should.equal(6);
      });
});

You should explain things with multiple "it"-s and "describe"-s if it is really needed. I think everybody knows what a factorial is, and if they don't, they can use google or should not develop the code.

Some of the projects (e.g. cucumber https://cucumber.io/ ) go even a step further and hide the implementation of the tests. So in theory even laymen can write feature files and let the developers do the implementation. In practice devs use to write feature files too, so I think that approach does not make much sense (ofc there are exceptions)...

ghost avatar Sep 11 '18 16:09 ghost