Search code examples
javascriptjasminecucumberbdd

Why Jasmine is called a "BDD" testing framework even if no "Given/When/Then" supported?


In the introduction of Jasmine, it says:

Jasmine is a behavior-driven development framework for testing JavaScript code.

I read several articles of BDD, and seems we should use 'Given/When/Then' to define "Scenario"s, which is what "cucumber" does. But in Jasmine, I can't see any of such methods.

Can we still call Jasmine a "BDD" testing framework even if it doesn't have such concept?


Solution

  • I'd describe Jasmine as a unit testing framework for javascript that has alot of syntactic sugar so that we can write our 'tests' more as specifications that describe behaviour. Mostly we use Given, When, Then when we are describing/specifying the overall behaviour of a system in the language of the business. When you are describing a component of a system, using natural language generally has fewer benefits - the greater detail required at lower levels of abstraction is better supported by a programming language.

    Now unit testing is a fundamental part of BDD, and jasmine supports this in a way that allows us to specify behaviour fairly eloquently, so yes it can definitely be a BDD testing tool/framework even if it only targets lower levels of abstraction.

    Cucumber only targets higher levels of abstraction. The fact that its pants at writing low level specifications doesn't make it any less a BDD testing framework (BDD collaboration tool).

    An interesting point is that to do BDD you really need two different testing tools, one to do the high level abstraction stuff, and another to do the lower level detailed specification stuff. Different tools for different tasks that are both part of the same process.

    Finally GWT really is just an implementation detail of scenario writing. Its a way of differentiating

    • setting up state G
    • describing an action W
    • examining the consequences of the action T