Myrmidex

TestsCoverageCredo

A light wrapper around StreamData. Generate any data on the fly, or model the underlying types and common fields of domain-specific structs or schemas, optionally using custom generators. Aimed at speeding up test setup, and maximizing reusability of factory data throughout testing and development.

Installation

Add to your list of test dependencies in mix.exs, optionally also including in dev if you want to be able to use:

def deps do
  [
    {:myrmidex, "~> 0.2.0", only: [:test, :dev]}
  ]
end

Usage

Produce a stream of generically representative data from any term:

iex> "🐜"
...> |> Myrmidex.many()
...> |> Enum.join(" ")
"🐩 🐰 🐡 🐂 🐏 🐁 🐋 🐤 🐪 🐭 🐏 🐨 🐋 🐁 🐚 🐤"

iex> %{species: "🐜"}
...> |> Myrmidex.affix(kingdom: "Animalia", class: "Insecta")
...> |> Myrmidex.many()
[
  %{
    kingdom: "Animalia",
    class: "Insecta",
    species: "🪰"
  },
  %{
    kingdom: "Animalia",
    class: "Insecta",
    species: "🐞"
  },
  ...
]

See the main module (h Myrmidex) for examples of mocking structs and schemas, defining custom generator schemas, or hooking generation to persistance via factories.

Design goals

Roadmap