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

kip
Image is an image processing library for Elixir. It is based upon the fabulous vix library that provides a libvips wrapper for Elixir. I...
574 16576 179
New
sasajuric
I’d like to announce a small library called boundaries. This is an experimental project which explores the idea of enforcing boundaries ...
New
woutdp
Hi! I wanted to introduce my latest project LiveSvelte. It allows you to render Svelte inside LiveView with end-to-end reactivity. It’s ...
New
jakub-zawislak
Hi everyone, I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
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
tmbb
I’ve published the first version of my Makeup library. It’s a syntax highlighter for Elixir in the spirit of Pygments, Currently it highl...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
tmbb
PhoenixWS - Websockets over Phoenix Channels Source code on Github here: https://github.com/tmbb/phoenix_ws Phoenix channels are a great...
New
gjaldon
As the title states, EctoEnum has just been updated after some time of hardly any activity in the repo. Here’s the latest release: https:...
New

Other popular topics Top

nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
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
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
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
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