Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/portasynthinca3/propex
An adaptation of PropEr for the Elixir world.
https://github.com/portasynthinca3/propex
elixir proper property-based-testing wip
Last synced: 18 days ago
JSON representation
An adaptation of PropEr for the Elixir world.
- Host: GitHub
- URL: https://github.com/portasynthinca3/propex
- Owner: portasynthinca3
- Created: 2023-10-21T03:42:13.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-21T03:49:32.000Z (about 1 year ago)
- Last Synced: 2024-12-16T20:38:51.198Z (26 days ago)
- Topics: elixir, proper, property-based-testing, wip
- Language: Elixir
- Homepage: https://hex.pm/packages/propex
- Size: 57.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PropEx
![shitpost-y logo](assets/logo.png)~~I swear this is not a shitpost~~
An adaptation of PropEr for the Elixir world.
**WARNING!:** As of right now, this is a prototype. Feel free to open issues and
send pull requests!## Installation
Add the library as a dependency for the `test` environment
```elixir
defp deps do
[
{:propex, "~> 0.1", only: :test}
]
end
```## Usage
Suppose that you want to test the following module:
```elixir
# lib/my_lib.ex
defmodule MyLib do
@spec add(a :: integer(), b :: integer()) :: integer()
def add(a, b), do: a + b
end
```### Automatic
You can automatically generate the argument list assuming that you had written
a `@spec` for your function:
```elixir
# test/my_lib_test.exs
defmodule MyLibTest do
use ExUnit.Case
use PropExtest "add/2" do
forall arguments_of MyLib.add/2 do
# a, b and result are assigned automatically
result - a == b &&
result - b == a
end
end
end
```### Manual
You can specify the variables and types yourself if you want to
```elixir
# test/my_lib_test.exs
defmodule MyLibTest do
use ExUnit.Case
use PropExtest "add/2" do
forall [a :: integer(), b :: integer()] do
MyLib.add(a, b) == a + b
end
end
end
```