Erlang Programming/Unit Testing with eunit

Installing eunit
This section will show you how to install eunit on different operating systems. Once you have installed eunit its use is fairly consistent across the different operating systems.

ubuntu
Get source with:

Compile code with:

Copy to

Test the Installation
To test that everything is installed ok before writing any tests create a file  with the following contents:

Compile this file as follows:

If you get the result  then you've installed eunit correctly.

Using eunit
We'll start by writing a passing test and a failing test. In the file you created to check the installation add the following: passing_test -> ?assert(true).

failing_test -> ?assert(false).

Run the tests as follows.

Eshell V5.5.5 (abort with ^G) 1> c(test01). {ok,test01} 2> test01:test. test01:failing_test...*failed*
 * error:{assertion_failed,[{module,test01},

{line,29}, {expression,"false"}, {expected,true}, {value,false}]} in function test01:'-failing_test/0-fun-0-'/0

=
========================================== Failed: 1. Aborted: 0. Skipped: 0. Succeeded: 3. error 3>