[ANN] ExecutableSpecifications.jl: Tool for Behavior Driven Development (like Cucumber)

Hi!

I created a new package for running executable specifications, like Cucumber (or closer to Pythons Behave actually). This is a tool that is part of doing Behavior Driven Development (BDD). If you have used Cucumber-like software for other languages you will have a good idea of what this tries to do.

Here is a link to GitHub:
https://github.com/erikedin/ExecutableSpecifications.jl

In short, you can write specifications in a (semi-)natural langugage, like this:

Feature: Coffee machine

    Scenario: Coffee with milk
        Given that the machine has both coffee beans and milk
         When the "Coffee with milk" button is pressed
         Then both coffee and milk is dispensed into the cup

Each Given, When, and Then executes a predefined function, defined like this:

using ExecutableSpecifications: @given, @when, @then, @expect
using CoffeeMachine

@given "that the machine has both coffee beans and milk" begin
    cup = CoffeeCup()
    machine = CoffeeMachine(cup, coffeebeans=100, milk=10)
    context[:machine] = machine
    context[:cup] = cup
end

@when "the "Coffee with milk" button is pressed" begin
    machine = context[:machine]
    machine.pressedCoffeeWithMilk()
end

@then "both coffee and milk is dispensed into the cup" begin
    cup = context[:cup]
    @expect hascoffee(cup)
    @expect hasmilk(cup)
end

One of the advantages of writing requirements like this is that non-developers can read and understand the Gherkin specifications, while still getting an executable test which can be run reliably and quickly.

My package is still in early development. It can read specifications and execute simple ones, but is not quite ready for use yet.

13 Likes

@erikedin Nice work :slight_smile:

1 Like

Cucumber supports a wire protocol that allows one to create executable steps in any language. It appears that Lua was hooked up as such. Maybe it would be good to do something similar here?

https://github.com/cucumber/cucumber-lua

Absolutely, the wire protocol is one way to go. I wanted something that you could run as part of runtests.jl though, without dependencies on other processes. To be fair, I’ve mostly used Pythons Behave package, so I’m basing my package heavily on how that works.

Version 0.1.0 of ExecutableSpecifications.jl is now available. It is now minimally usable, by which I mean that it can be used, but still lacks niceties and certain features.

2 Likes