Running a Property
Learn to run a property in Erlang.
We'll cover the following
The properties we’ve seen so far were pseudocode-like and left a lot to the imagination. Now that we have a stand-in directory structure with a structure similar to what we’d have in a real project, we’re going to tie everything together. We’ll add a property to the project and execute it. The property will be basic and test nothing of significance, but it’ll give us a brief idea of what things look like and how they should all fit together.
Properties in practice
PropEr’s properties are not located within the same module as our production source code. Instead, we’ll enforce a strict separation of production and test codes by forcing all properties to be placed in standalone modules under the test/
directory.
Properties must be added to modules that have a name starting with prop_
. Besides this, they are regular Erlang codes. We can add a module named prop_foundations
under test/prop_foundations.erl
, or we can also use templates to do the same thing for us by calling the following command within the project’s root directory:
rebar3 new proper foundations
Take a look at the created file in the code widget below
We can run the test in the code below:
Note: To execute the code after changing it, please click “Run,” which will save your code, and then run
rebar3 proper
in the terminal.
Get hands-on with 1400+ tech skills courses.