hauleth

hauleth

Watermelon - yet another Gherkin BDD testing tool

Watermelon is the small library for BDD that uses Gherkin syntax. This library is heavily inspired by the Cabbage, but takes slightly different approach for defining steps and modularity of the implementation. Additionally it implements Cucmber expressions right now (Cabbage is working on supporting that).

Usage is quite simple:

defmodule MyTest do
  use ExUnit.Case, async: true
  use Watermelon.Case

  # Here we use inline feature description, but you can use `feature_file/1`
  # which will import file from `test/features` directory (can be changed
  # via configuration)
  feature """
  Feature: Example
    Scenario: simple test
      Given empty stack
      And pushed 1
      And pushed 2
      When execute sum function
      Then have 3 on top of stack
  """

  defgiven match when "empty stack", do: {:ok, stack: []}

  defgiven match(val) when "pushed {num}", context: %{stack: stack} do
    {:ok, stack: [val | stack]}
  end

  defwhen match when "execute sum function", context: ctx do
    assert [a, b | rest] = ctx.stack

    {:ok, stack: [a + b | rest]}
  end

  defthen match(result) when "have {num} on top of stack", context: ctx do
    assert [^result | _] = ctx.stack
  end
end

Which will be rough equivalent of:

defmodule MyApp.FeatureTest do
  use ExUnit.Case, async: true

  test "simple test" do
    stack = [1, 2]
    assert [a, b | _] = stack
    assert 3 == a + b
  end
end

Documentation can be found on HexDocs, it is not perfect yet, but I hope to improve it in near future.

Most Liked

hauleth

hauleth

I have released version 0.2.0-pre.0 of Watermelon that supports scenario outlines and data tables

There is discussion how data tables should be handled, so if anyone has any insights, then these will be welcome in the issue.

From now I find it as a mostly feature-complete solution that from now I will try to document better before 1.0.0.

Hisako1337

Hisako1337

Awesome! Looks like we will have a sleek successor to white_bread soon? :slight_smile:

Where Next?

Popular in Libraries Top

ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
arkgil
Hi all! I’m happy to announce that Telemetry v0.3.0 is out! This release marks the conversion from Elixir to Erlang so that all the libr...
New
Eiji
ExApi is a library that I’m developing now and hope release soon This library will allow to: list all apis list all api implementation...
New
mcrumm
If you would like to migrate away from node/npm/webpack while still using sass, the dart_sass package provides a installer and runner for...
New
riverrun
I’ve just released version 3 of Comeonin, a password hashing library. The following small changes have been made: changes to the NIF c...
New
tfwright
After working on it for a couple of months and using it in production for most of that time, today I’ve released LiveAdmin, a LiveView ba...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
engineeringdept
I’ve just released the first version of Snap, an Elasticsearch client. It borrows ideas about application structure and process managemen...
New
Crowdhailer
Experimenting with this code. OK.try do user <- fetch_user(1) cart <- fetch_cart(1) order = checkout(cart, user) save_or...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
381 12391 119
New

Other popular topics Top

lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

Sub Categories:

We're in Beta

About us Mission Statement