Glide
Library to help generating test data using StreamData.
It adds several generators for commonly used values and some convenience wrappers for StreamData, allowing you to generate test data for your tests. The test data is reproducible, i.e. it will use the same seed ExUnit uses, so you'll get the same data if you supply the same seed.
The generators can be used as a stepping stone for property based tests at a later stage.
Installation
The package can be installed by adding glide to your list of dependencies in mix.exs:
def deps do
[
{:glide, "~> 0.9.0"}
]
endUsage
In your tests you can either import or alias Glide depending on your preference
With import syntax it will look like
import Glide
gen(:uuid) # creates generator
val(:uuid) # builds val from generator
gen(:uuid) |> val() # builds val from generatorIf you want to use an alias:
alias Glide, as: G
G.gen(:uuid) # creates generator
G.val(:uuid) # builds val from generator
G.gen(:uuid) |> G.val() # builds val from generatorInstead of the wrapper functions, you can also use StreamData directly for more control.
StreamData.integer() |> G.valExamples
Create fixed map, with optional subtitle
gen(:fixed_map, %{post_id: gen(:uuid), subtitle: optional(gen(:string, [:ascii]))})