Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is difference between BDD and specifications by example?

I know BDD and also read Specification by Example the great book by Gojko Adzic; As I understand they are almost the same and have many in common; But I was not able to understand their main difference. I mean Can we use them interchangeably?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

General idea

BDD is the format of describing tests in a form of "this functionality does this and that". If requirements are written in the same format, then we end up with the whole team using BDD. Because these requirements can be reused for testing.

Specs by example is.. well, putting a particular example into the requirements.

Testing formats

BDD-for-testing can come in different forms:

  • Given When Then
  • Gherkin (a more strict dialect of G/W/T used by Cucumber family of frameworks)
  • Describe-it (Jasmine, Mocha, etc)
  • Or something custom. Could be same old JUnit with tests named as "adminHasAccessToProfileOfOthers" instead of older style "testAdminCanAccessProfileOfOthers"

Requirements

As for BDD-for-requirements, here’s an example:

If user has sufficient amounts of money, they can buy the product

And here is Specs-by-example:

If user has 10$ and the product is 9$, user can buy that product

See, in the 1st example we used abstract ideas, while in the latter one we used particular values.

Oftentimes when people talk about BDD/Specs-by-example, they would write requirements using Given-When-Then. But as an abstract idea this isn’t compulsory – it’s just what most testing frameworks support it.

Overall, BDD is a very good idea for testing, especially if it’s not a Given-When-Then 🙂 But when it comes to requirements – I haven’t seen any project in my experience that really benefited from it.

As for other common misconceptions: BDD and how it does NOT relate to TDD.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading