{"id":15668305,"url":"https://github.com/devstopfix/given-exunit","last_synced_at":"2025-03-30T04:42:15.501Z","repository":{"id":179878125,"uuid":"664237516","full_name":"devstopfix/given-exunit","owner":"devstopfix","description":"Feature testing micro-library for Elixir's ExUnit","archived":false,"fork":false,"pushed_at":"2023-07-19T13:56:29.000Z","size":89,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T06:49:13.219Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devstopfix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-09T10:49:47.000Z","updated_at":"2023-07-19T13:52:04.000Z","dependencies_parsed_at":"2023-11-15T10:50:50.768Z","dependency_job_id":null,"html_url":"https://github.com/devstopfix/given-exunit","commit_stats":{"total_commits":85,"total_committers":1,"mean_commits":85.0,"dds":0.0,"last_synced_commit":"3a7fc412a0c74ca520289efa1c6061ec5d105056"},"previous_names":["devstopfix/given-exunit"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstopfix%2Fgiven-exunit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstopfix%2Fgiven-exunit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstopfix%2Fgiven-exunit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstopfix%2Fgiven-exunit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devstopfix","download_url":"https://codeload.github.com/devstopfix/given-exunit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246277352,"owners_count":20751548,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T14:08:00.594Z","updated_at":"2025-03-30T04:42:15.479Z","avatar_url":"https://github.com/devstopfix.png","language":"Elixir","readme":"# Given ExUnit\n\nGiven-When-Then is a style of representing tests of specifying a system's\nbehaviour using specification by example - [Martin Fowler][gwt].\n\nThis is a micro library that is a lite extension to ExUnit and prefers \npattern matching over regular expressions. There are other BDD libraries\nbut they do not seem to be maintained. The advantages of Given are:\n\n1. no regular expressions\n2. pattern match errors are clear and obvious\n3. line numbers in errors are accurate as there are no separate text files\n\nWe use a parser to split clauses into words, strings, integers and dates then\ncall functions and rely on pattern matching to build up a test state. The input\nis the standard context created with the `setup` and `setup_all` callbacks\nand this context is passed from clause to clause with new data appended.\n\nHere is a working example using the [peek at elixir-lang.org][ex]:\n\n```elixir\ndefmodule Given.ReadmeTest do\n  use ExUnit.Case\n  use Given.Case\n\n  describe \"elixir-lang.org\" do\n    scenario \"peek\", ~s\"\"\"\n    Given the string \"Elixir\"\n    When graphemes\n    And frequencies\n    Then \"i\" occurs 2 times\n    And \"E\" occurs 1 time\n    \"\"\"\n  end\n\n  # Pre-conditions\n  def given_({:the_string, s}, _), do: [str: s]\n  # Actions\n  def when_({:graphemes}, %{str: s}), do: [gs: String.graphemes(s)]\n  def when_({:frequencies}, %{gs: gs}), do: [freq: Enum.frequencies(gs)]\n  # Post-conditions\n  def then_({l, :occurs, n, _}, %{freq: freq}), do: assert n == freq[l]\nend\n```\n\nSee the [Case module][case] for the syntax of the scenarios and \nthe [Parser module][parser] contains the terms that can be used.\n\n[![CI](https://github.com/devstopfix/given-exunit/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/devstopfix/given-exunit/actions/workflows/ci.yml)\n\n## Installation\n\n```elixir\ndef deps do\n  [\n    {:given, \"~\u003e 1.22\", only: [:test, :dev]}\n  ]\nend\n```\n\n### Testing\n\nWhen changing the grammar or the parser, run tests with:\n\n    PROPCHECK_NUMTESTS=20000 mix test\n\nRun deliberately failing tests with:\n\n    mix test --only failing_test\n\n\n[case]: https://hexdocs.pm/given_exunit/Given.Case.html\n[parser]: https://hexdocs.pm/given_exunit/Given.Parser.html\n[docs]: https://hexdocs.pm/given_exunit\n[ex]: https://elixir-lang.org\n[gwt]: https://martinfowler.com/bliki/GivenWhenThen.html","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevstopfix%2Fgiven-exunit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevstopfix%2Fgiven-exunit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevstopfix%2Fgiven-exunit/lists"}