cucumberelixirgherkinex-unitcabbage

Isolating scenarios in Cabbage


I am automating acceptance tests defined in a specification written in Gherkin using Elixir. One way to do this is an ExUnit addon called Cabbage.

Now ExUnit seems to provide a setup hook which runs before any single test and a setup_all hook, which runs before the whole suite.

Now when I try to isolate my Gherkin scenarios by resetting the persistence within the setup hook, it seems that the persistence is purged before each step definition is executed. But one scenario in Gherkin almost always needs multiple steps which build up the test environment and execute the test in a fixed order.

The other option, the setup_all hook, on the other hand, resets the persistence once per feature file. But a feature file in Gherkin almost always includes multiple scenarios, which should ideally be fully isolated from each other.

So the aforementioned hooks seem to allow me to isolate single steps (which I consider pointless) and whole feature files (which is far from optimal).

Is there any way to isolate each scenario instead?


Solution

  • First of all, there are alternatives, for example: whitebread.

    If all your features, needs some similar initial step, maybe background steps are something to look into. Sadly those changes were mixed in a much larger rewrite of the library that newer got merged into. There is another PR which also is mixed in with other functionality and currently is waiting on companion library update. So currently that doesn't work.

    Haven't tested how the library is behaving with setup hooks, but setup_all should work fine.

    There is such a thing as tags. Which I think haven't yet been published with the new release, but is in master. They work with callback tag. You can look closer at the example in tests.

    There currently is a little bit of mess. I don't have as much time for this library as I would like to.

    Hope this helps you a little bit :)