Example-based Tests
Get to know the example-based tests and tabular tests.
We'll cover the following
Example-based tests
When writing tests, we usually write something that we could call example-based tests. In this lesson, we’ll have a new look at them from the perspective of the inputs that we feed to our code. We’ll define terminology to identify example-based tests, which will help us later compare them to property-based tests.
Let’s start with an example. Let’s say we want to test that the Enum.sort/1
function correctly sorts lists. Take a look at property_based_testing/sorting/test/example_based_sort_test.exs
. We could call the following an example-based test because it verifies that the code we want to test (Enum.sort/1
in this case) works by giving a few examples of how it should work:
Get hands-on with 1400+ tech skills courses.