BDD in JavaScript

SUMMARY

  • Origins
  • TDD & BDD or TDD vs BDD ?
  • Demo
  • Pros/cons

BDD comes from TDD

Introduces in 2006 in Better Software magazine

- Dan North

TDD was too hard to explain

Developers didn't use TDD

Yeah, keep in mind they were Java Developer

BDD must be simpler to understand

Behavior Driven Development

Don't write a test, describe a behaviour !

Use a natural langage

Gherkin

Natural langage

Feature: getNumberOfSuperLi

    Scenario: There is no Super li elements
        Given QuerySelector API returns an empty array
        When it returns the number of found elements
        Then the number of found elements should be 0

Actually, the well known solution to write BDD scenario in "natural language"

BDD is testing for non-developer

So, I can make TDD with BDD ?

Yes !

But, you should not do that

BDD is too fat for unit testing

Natural langage to code

Is expensive

Unit Demo

BDD is for high level checking

like User Interface

or API

UI Demo

BDD & TDD can be used together

Pros

  • More comprehensive
  • Can be written by every one, including PO !
  • Ensure all pieces work well together

CONS

  • Ask a strong investissement

CONCLUSION

BDD is really powerful in an agile organisation

 

Like TDD, it should not be a dogma

 

Can be seen like write it own testing framework ...

Some questions ?

BDD in JavaScript

By Mathieu Breton

BDD in JavaScript

  • 1,661