Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cucumber.js for BDD unit testing?

I am wondering if it is possible to use cucumber(js) for BDD unit testing? Cucumber is known to be runable as a acceptance testing framework. But I have never seen examples if and how cucumber may be used as a BDD unit testing.

Is cucumber able to provide unit tests? Is it uncommon to use cucumber for unit testing?

like image 900
cilap Avatar asked Feb 06 '15 18:02

cilap


2 Answers

BDD is a process/mechanism for driving development by using high level descriptions of the the behavior of the application. Cucumber (in all its forms) is a tool for supporting this process by allowing you to specify high level concepts in a natural language that can be automated. It is not a tool for writing unit tests.

Cucumber is a tool for the outer circle of the BDD process

BDD two circles diagram

But as you can see BDD has an inner circle where unit testing takes place.

When you are in the inner circle sometimes you have to build things to make the outer circle green (other times you will just use existing things). When you build things you require unit tests. In the inner circle the level of abstraction is lower, the amount of detail is much greater, and exhaustive testing is much more important. These combine to make using cucumber for these tests prohibitively expensive and difficult. This is why unit testing tools are a better fit here.

like image 182
diabolist Avatar answered Oct 05 '22 17:10

diabolist


I think this is absolutely correct, please find examples here and here

like image 36
Eugene Avatar answered Oct 05 '22 19:10

Eugene