{"id":13509189,"url":"https://github.com/parroty/excheck","last_synced_at":"2025-10-21T15:15:24.864Z","repository":{"id":11768650,"uuid":"14304754","full_name":"parroty/excheck","owner":"parroty","description":"Property-based testing library for Elixir (QuickCheck style).","archived":false,"fork":false,"pushed_at":"2018-09-24T14:47:20.000Z","size":88,"stargazers_count":316,"open_issues_count":9,"forks_count":26,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-28T22:20:49.433Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/parroty.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-11T15:29:32.000Z","updated_at":"2024-12-11T01:00:43.000Z","dependencies_parsed_at":"2022-09-26T18:00:52.807Z","dependency_job_id":null,"html_url":"https://github.com/parroty/excheck","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parroty%2Fexcheck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parroty%2Fexcheck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parroty%2Fexcheck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parroty%2Fexcheck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parroty","download_url":"https://codeload.github.com/parroty/excheck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246323932,"owners_count":20759051,"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-08-01T02:01:04.302Z","updated_at":"2025-10-21T15:15:19.812Z","avatar_url":"https://github.com/parroty.png","language":"Elixir","funding_links":[],"categories":["Testing"],"sub_categories":[],"readme":"# ExCheck [![Build Status](https://secure.travis-ci.org/parroty/excheck.svg?branch=master \"Build Status\")](http://travis-ci.org/parroty/excheck) [![Coverage Status](http://img.shields.io/coveralls/parroty/excheck.svg)](https://coveralls.io/r/parroty/excheck) [![Inline docs](http://inch-ci.org/github/parroty/excheck.svg?branch=master\u0026style=flat)](http://inch-ci.org/github/parroty/excheck)\n\nProperty-based testing for Elixir (QuickCheck style).\nIt uses Erlang's [triq](https://gitlab.com/triq/triq) library for underlying checking engine, and ExCheck's modules provide wrapper macros for ExUnit tests.\n\n### Installation\n\nFirst add ExCheck and triq to your project's dependencies in mix.exs.\n\n```Elixir\n  defp deps do\n    [\n      {:excheck, \"~\u003e 0.6\", only: :test}\n    ]\n  end\n```\nYou need to have erlang-eunit installed in order to build triq.\n\nand add the following to test_helper.exs:\n\n```Elixir\nExCheck.start\n# ... other helper functions\nExUnit.start\n```\n\n### Configuration\nYou can also specify the amount of tests that you want to run for each property\nby adding the following to your config.exs:\n\n```Elixir\nuse Mix.Config\n# import \"#{Mix.env}.exs\"  # If you want to specify different amount for each environment\n\n# And then in this file (or different amount in each config file):\nconfig :excheck, :number_iterations, 200\n```\n\n### Usage\nThe following is an testing example. `ExCheck.SampleTest` is the testing code for `ExCheck.Sample`.\n\n#### Test\n\n```Elixir\ndefmodule ExCheck.SampleTest do\n  use ExUnit.Case, async: false\n  use ExCheck\n  alias ExCheck.Sample\n\n  property :square do\n    for_all x in int(), do: x * x \u003e= 0\n  end\n\n  property :implies do\n    for_all x in int() do\n      #implies skip samples that does not satisfy the predicate. Also, it prints x when skip a sample\n      implies x \u003e= 0 do\n        x \u003e= 0\n      end\n    end\n  end\n\n  property :such_that do\n    for_all {x, y} in such_that({xx, yy} in {int(), int()} when xx \u003c yy) do\n      x \u003c y\n    end\n  end\n\n  property :concat_list do\n    for_all {xs, ys} in {list(int()), list(int())} do\n      Enum.count(Sample.concat(xs, ys)) == Enum.count(xs) + Enum.count(ys)\n    end\n  end\n\n  property :push_list do\n    for_all {x, y} in {int(), list(int())} do\n      result = Sample.push(x, y)\n      Enum.at(result, 0) == x and Enum.count(result) == Enum.count(y) + 1\n    end\n  end\n\n  # specify iteration count for running test\n  @tag iterations: 30\n  property :square_with_iteration_count do\n    for_all x in int(), do: x * x \u003e= 0\n  end\nend\n```\n\n#### Code\n\n```Elixir\ndefmodule ExCheck.Sample do\n  @moduledoc \"\"\"\n  Sample logic to be tested by ExCheck (refer to sample_test.exs for tests)\n  \"\"\"\n\n  @doc \"concatenate the list\"\n  def concat(x, y) do\n    x ++ y\n  end\n\n  @doc \"push element in the list\"\n  def push(x, y) do\n    [x|y]\n  end\nend\n```\n\n#### Run\n\n```Shell\n mix test test/sample_test.exs\n..................................................................................................................................................................................................................xxx....x.xx..xxx.x.xx.xx..x...x..x..xx.xx..xx.xx.x..x.x..x..x......x.xx............x.x..x..x...xxx..x..x..xx.x..xx.xx.x......x.xxx.xx..xx.x.x.x.xx.x.xx......xx..xxxx..x....xxx.xxxxx.xxxxx..xx...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................\n\nFinished in 0.2 seconds (0.1s on load, 0.08s on tests)\n948 tests, 0 failures\n```\n\nYou can also add the optional flag --trace to get additional output\n```Shell\nmix test test/sample_test.exs --trace\n\nExCheck.SampleTest\n  * implies_property........xx.x.x..x..xx.xxx..x.x.x.x..x..x..xx....x.x.xx.xxxxxx..xx...x...xx.x...x.x..xxxxx..x...x......xxxxx.x.x..xxx.x..x.xx..xx..xxxx.x.x..xx.......x..xx.xx...x...x...xxx.xxx.x.xx.xx  * implies_property (14.7ms)\n  * square_property........................................................................................................................................................................................  * square_property (4.1ms)\n  * push_list_property.....................................................................................................................................................................................  * push_list_property (14.7ms)\n  * square_with_iteration_count_property (0.7ms)......................\n  * such_that_property.....................................................................................................................................................................................  * such_that_property (4.8ms)\n  * concat_list_property...................................................................................................................................................................................  * concat_list_property (25.4ms)\n\n\nFinished in 0.1 seconds (0.1s on load, 0.06s on tests)\n942 tests, 0 failures\n```\n\n\nThere are some more examples at \u003ca href=\"https://github.com/parroty/excheck/tree/master/test\" target=\"_blank\"\u003etest\u003c/a\u003e directory.\n\n### Generators\nThe following generators defined in :triq are imported through \"use ExCheck\" statement.\n\n- list/1, tuple/1, int/0, int/1, int/2, byte/0, real/0, sized/1, elements/1, any/0, atom/0, atom/1, choose/2, oneof/1, frequency/1, bool/0, char/0, return/1, vector/2, binary/1, binary/0, non_empty/1, resize/2, non_neg_integer/0, pos_integer/0,\n- unicode_char/0, unicode_string/0, unicode_string/1, unicode_binary/0, unicode_binary/1, unicode_binary/2, unicode_characters/0, unicode_characters/1,\n- bind/2, bindshrink/2, suchthat/2, pick/2, shrink/2, sample/1, sampleshrink/1, seal/1, open/1, peek/1, domain/3, shrink_without_duplicates/1\n\n\n### Notes\n\n- It's a trial implementation, and has limited functionalities yet.\n- Files in test folder contains some more property examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparroty%2Fexcheck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparroty%2Fexcheck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparroty%2Fexcheck/lists"}