hauleth

hauleth

Guidance Counsellor

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.

Showing Posts 1 to 2

Hisako1337

Hisako1337

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

hauleth

hauleth OP

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.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
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
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews