[ANN] Cucumber.ml 1.0.0

Today I would like to announce the 1.0.0 release of Cucumber.ml, which brings Behaviour Driven Development via Cucumber to OCaml. Before I start though, I would like to thank @Thegaram for his contributions and feedback.

I am declaring this 1.0.0 because I wanted to avoid the “forever beta” issue and most of the main features for using Cucumber are implemented so I decided to “just do it”.

Why?

While many of OCaml’s language features tend to reduce the need for testing in general, I still feel that communicating between stakeholders and programmers is important and Cucumber is well-placed to help in that. Additionally, I felt that this was a good way for me to contribute to the OCaml ecosystem in a positive way.

Installing

There are a few complications when working with Cucumber.ml. The first and the most important is that Cucumber.ml delegates its Gherkin parsing to the gherkin-c implementation using OCaml’s C interface. I did not use CStubs for this because I am not familiar with it and I needed to deal with wchar_t that is used in the gherkin-c and I did not know how to deal with that type via CStubs. This means that, before you can use Cucumber.ml, you will need to compile and
install the gherkin-c as a shared library on your system. On Linux, this means you will need to install libgherkin.so in /usr/lib and copy the gherkin-c header files into /usr/include/gherkin.

Cucumber.ml uses the Dune build system. Unfortunately,
I have not yet added Cucumber.ml to the Opam package manager. If anyone would like to help me do that, I would be very grateful.

Once you have checked out the code and have the above prerequisites installed, all you need to do is:

dune build && dune install

which will install the cucumber package into your local Opam repository. From there you can write your step definitions in OCaml and run your feature files against them. For more information on how
to use Cucumber.ml, please see the Cucumber.ml README file in the repository.

One of the more unusual aspects of Cucumber.ml is that it assumes that once you start executing your step definitions that it will control the command line arguments (and uses Cmdliner for that purpose). This can be surprising so please be aware of it. Basically, the executable created by the compilation process
is the cucumber runner and it is that executable which will run your step definitions.

Features

There are many features that come with Cucumber.ml.

  • Gherkin 5.0 is supported (Feature, Background, Given, When, Then, etc.)
  • Datatable transforms (the user can define transformations for datatables but this is not done automatically and must be applied by the user)
  • Before and After steps
  • State passing is handled by the runner and is passed to Step definitions automatically

The state passing feature is, I believe, a first for a Cucumber implementation.

Roadmap

Cucumber.ml will work today and please let me know if you would like any more features. However, here are a few things that I (or anyone else who wants to contribute) will be working on.

  • Update to Gherkin 6.0 using
    gherkin-go
  • Lwt threading
  • Bring Cucumber.ml fully within the Opam package manager

My main focus will be the first task on the list so I am looking forward to moving to the gherkin-go universal runner.

I hope you enjoy using it as much as I have had making it. If you have
any questions, you can ask on the Cucumber Slack or you can drop an issue on the Github issue tracker.

1 Like