Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QUnit Vs. Jasmine and TDD Vs. BDD

I've been looking at two libraries for doing unit tests on the front-end.

  • QUnit - http://qunitjs.com/

  • Jasmine - http://jasmine.github.io/

    1. Jasmine is clearly more BDD focused than QUnit although I could see doing BDD with QUnit by describing the tests in a behavior-oriented way. Both of them are able to run assertions on units of code so I think they're both unit tests. Is BDD mutually exclusive from TDD or is it all in how you write it?

    2. Is unit testing necessary if you're doing behavior testing? Seems like if you cover all user stories, you don't really need to know the details of the testable units.

    3. Are there any other testing frameworks you like? Are there other tests besides unit tests that are good for devs to do on the front-end?

like image 247
Mims H. Wright Avatar asked Aug 09 '13 20:08

Mims H. Wright


People also ask

Is Jasmine BDD or TDD?

Even though the Jasmine website tells us that Jasmine is a BDD framework, you can also use it with TDD and unit testing.

Is BDD a replacement for TDD?

Not at all. BDD is just a variant of TDD. In TDD, you formulate your requirements as an executable test, then write the production code to fulfill the test.


1 Answers

  1. BDD and TDD are not mutually exclusive. See Liz Keogh's post

  2. Behavior testing should be understandable by business stakeholders. Unit testing is typically intended to be understood by technical team members (developers, testers etc.). For examples of how to make unit tests more readable you should look at the GOOS book (although the examples are Java not Javascript).

    Also, if you try to cover all test paths using BDD, your business people will get bored and stop caring.

  3. Have a look at Cucumber-JS (a port of Cucumber).

like image 79
Seb Rose Avatar answered Sep 30 '22 17:09

Seb Rose