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.
Add to your list of test dependencies in mix.exs
, optionally also including
in dev
if you want to be able to use in IEx:
def deps do
[
{:myrmidex, "~> 0.3.1", only: [:test, :dev]}
]
end
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.
- Initial, usable defaults, which can be extended with domain-specific concerns
- Decouple any requirements wrt to seeding a datasource from the generation of data
- Avoid unnecessary dependencies and testing setup
- Avoid any kind of dsl (besides that introduced by StreamData in
ExUnitProperties
, which is useful for property-based testing) - Rely on reflection and introspection as much as possible to avoid boilerplate and repetition, and also to keep factories in sync with schemas
- Establish a robust, composable api from which to generate mock data in many situations: test setup, dev setup, prototyping, etc., testing changesets and validation vs testing context functions, and so on.
- Reduce the complexity (and conversely, increase the flexibilty & reusability) involved in mocking schemas with associations, or other interdependencies between fields
- Retain compatibilty with StreamData and property testing
Better generation of vanilla maps and lists- Reporting on generated terms
- Better defaults for strings/emails etc.
- Option to control shrinking
- Option to control the default count
- Inference/generation of ISO dates and datetimes
- Better integration with vanilla streams