Property-Based Testing with StreamData
Go beyond example-based tests by generating hundreds of random inputs with StreamData to find edge cases ExUnit examples miss.
What is Property-Based Testing?
Traditional tests check specific examples. Property-based testing describes a rule that should hold for all inputs, then generates many random inputs to try to break it.
It excels at finding edge cases you never thought to write by hand.
Adding StreamData
StreamData is the Elixir library for generating test data. Add it to your dependencies.
defp deps do
[{:stream_data, "~> 0.6", only: :test}]
endAll lessons in this course
- Unit Testing with ExUnit
- Integration Testing Phoenix Applications
- Mocking, Stubs, and Test Data
- Property-Based Testing with StreamData