File Structure

Understand the test file structure of Erlang and Elixir, as well as the sections in the test file.

General file structure

The prop_base file created in Erlang and the pbt_test.exs file created in Elixir are the test files of the projects. Both have a similar structure, so let’s look at what that structure is.

Elixir creates the test files by itself. However, Erlang does not. In the root of any standard Erlang project, call the rebar3 new proper base command to generate a test file named prop_base.erl.

The files contain two parts:

  1. The test module, module(prop_base) for Erlang and defmodule PbtTest for Elixir.
  2. A test suite which contains three sections:
    • The properties we want to test
    • The helper functions
    • The custom data generators

Get hands-on with 1200+ tech skills courses.