...

/

Writing Property Tests with ExUnit

Writing Property Tests with ExUnit

Learn how to write property tests using ExUnit and StreamData.

Exploring ExUnit and StreamData

Elixir makes testing a breeze using its testing framework, ExUnit. ExUnit is a framework for writing unit tests that is built-in to every Elixir project. Every time we create a new project using mix new, Elixir will automatically create a test directory for us and populate it with a skeleton for writing unit tests for our project. ExUnit is already packaged with Elixir, so we don’t need to install any dependencies.

StreamData is an Elixir library for writing property-based tests. Property-based tests test the properties of a function to ensure our code meets some specified properties every time. Property-based tests are especially useful when functions contain randomness because we can write tests that run hundreds of times and ensure the functions meet specified properties and behaviors. For example, if we had a function that generated lists of length 10 of random integers ...

Access this course and 1400+ top-rated courses and projects.