
Given that a user arrives to any pageSounds pretty straight forward - one of the pros of using Cucumber is that your test scenarios are pretty much self-documenting. Once you write this scenario, you start executing it in Cucumber which will keep failing until it succeeds. When you will run it the first time, Cucumber will not understand any of this. As you keep going, you will have to define "that a user arrives to" in Cucumber in order for the first step to pass. Then you will have to define "no session exists", and then "user is redirected to". So gradually you will be explaining to Cucumber what it is that your test case is doing.
When no session exists
Then user is redirected to Login page
My initial impression was that this is way too cool. Looking from the outside, you can basically read the code in plain English which simplifies readability and understanding of what it is you are testing. But once I started looking at it a bit deeper, it occurred to me that testing this way on a serious project can be really dangerous. Here is why.
Cucumber Imposes Endless DSLs
This comment may go towards BDD in general. Basically Cucumber allows you to create an endless Domain Specific Language (DSL) for your tests. Any new or existing developer can just "speak" his mind to Cucumber which will inevitably lead to more and more new "key phrases" for the overall DSL. In my view this may significantly hinder reusability of test cases and pretty soon you may end up in a position where you have thousands upon thousands of unmaintainable Cucumber scenarios. If you look at GridGain test cases for example (and we have about a thousand of test cases), we managed to keep them very concise only because they are mostly reusing existing test components available to them. One may argue that you can do the same in Cucumber, but this would be against overall Cucumber philosophy in my view.
Enterprises Need Structure
Yes, enterprise projects need structure and developers need to be constrained by available libraries and APIs. You cannot just let every developer go willy-nilly by allowing him to "talk freely" to the underlying testing framework. I have nothing against a specific DSL for testing (on the contrary, I would encourage it), but this DSL should be well defined and used by everyone in the company.
I should mention, however, that on a relatively small project, testing the Cucumber way may be very productive. Since small projects are exactly the sweet spot for Ruby, Cucumber may very well be the best testing framework available for Ruby. But as the project will grow, using Cucumber will become more and more painful and unmaintainable.
So, here is the test scenario for GridGain that you could create in Cucumber (forgive the sarcasm, but I couldn't resist):
Given that GridGain is a large enterprise project
When I write test scenarios in Cucumber
Then I will shoot myself in the foot
P.S. I realize that this post may stir some disapproval from Cucumber community. In the interest of full disclosure I want to mention that I have not used Cucumber on a real project and simply am expressing my opinion here which is not based on actual project experience.
Add a comment