1

I'm curious, I'm only just beginning a journey into the BDD and wondering if there any advantages to the languages which Cucumber (Gherkin) can translate to? I note that some languages are not officially supported but looking for a personal opinion?

Ideally I would like to write it in either Python or Ruby.

5 Answers 5

3

Python, Ruby, Java all are very suitable for BDD.
For Java + Cucumber you get a lot of support in my experience. Also, you have nice plugins like CucumberReporting
I think Python should be good too.
I would choose the language based on:

- Toolstack your team uses (so that if you need a helping hand you can get it)
- Language you are more comofortable with

1

I would suggest to pick the same programming language as the application is developed in. This way you can possibly re-use application code to make test fixture setup easier.

Cucumber is originally designed as a collaboration tool (by applying specification by example), so the used programming language is not so relevant, more convenience. It is not a testing tool, be sure to read: https://cucumber.ghost.io/blog/the-worlds-most-misunderstood-collaboration-tool/

Cucumber was initial written in Ruby so you should be fine there. For Python have a look at behave, which is a Cucumber implementation for Python still under development.

0

Specifically for Cucumber?

I'd say no. If I start to comment on languages I like and don't, etc. it will not be from a 'cucumber' perspective. It's really tempting to extols the attributes of one language or a paradigm (disclosure I'm an untyped Ruby / Python fan) but I don't think it is very relevant, again, to Cucumber specifically.

So my advice comes from:

  • What is used in your workplace, your community, your friends ?
  • What is popular and trending so you can get lost of advice to problems ?
  • What language will be of most benefit to your career in the future ?

Given this I would generally recommend Python and Javascript as good languages to focus on. Python for back end and more traditional UI testing with Selenium and Javascript, using Jasmine, Jest, etc. for the plethora of js libraries currently on the landscape. I would choose Python over Ruby due to gaining/waning interest in the two (Ruby waning, Python gaining). I base this on the data in the Stack Overflow Annual Surveys

Another viewpoint is: Black Box or White Box testing.

If Black Box, the language will matter less. If white box (internal code or access points are known/exposed) then the application code language would be more relevant and there would be many communication benefits to using the same language.

0

I've been working with Python / Behave for around 3 years now, python's flexibility in what it can drive has been crucial.

Behave's flexibility on the interpretation of the Cucumber has also been very handy - there's a simple match mechanism, but if required it's possbile to go to full regular expressions and use those, and define choice fields too (where a specific parameter can be locked down to specific choices). Additionally, it's possible to automatically generate some smart, searchable HTML documentation on the library of cucumber phrases using simple tools.

Prior to using Behave, I hadn't worked in BDD or done much work in Python. I'm impressed with what the combination can do: in my case, it's driving selenium, C# assemblies, and several C API DLLs, as well as a training-set driven Python audio characterisation library, and it seems to do this pretty well (it's a highly complex system).

I haven't tried other languages (Java, etc) but I can definitely recommend Python / Behave.

0

My suggestion would be to choose the programming language based on comfort of the programmers (that will you and your team). Cucumber/BDD is for the people (aka domain experts) who describe how the application works (that is the application behavior). Cucumber/Gherkin allows them to describe their requirements in a more domain friendly way. Now, your job is to give meaning to their description/requirements. This will be best achieved if done in a programming language in which you are comfortable. The advantage lies in the methodology of BDD rather than the programming language used. Anyways, both python and ruby you do well. This is the methodology followed by test automation services.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.