From e5b8d638ea7293ae8a6d65386aefbb0d30aa254c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 28 Aug 2017 16:36:33 +0200 Subject: Update user guide --- guide/eunit.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'guide/eunit.html') diff --git a/guide/eunit.html b/guide/eunit.html index d211887..71c5bbb 100644 --- a/guide/eunit.html +++ b/guide/eunit.html @@ -33,9 +33,9 @@ div.navfooter{margin-bottom:1em}
-

Chapter 16. EUnit

EUnit is the tool of choice for unit testing. Erlang.mk +

Chapter 17. EUnit

EUnit is the tool of choice for unit testing. Erlang.mk automates a few things on top of EUnit, including the -discovery and running of unit tests.

16.1. Writing tests

The EUnit user guide +discovery and running of unit tests.

17.1. Writing tests

The EUnit user guide is the best place to learn how to write tests. Of note is that all functions ending with _test or _test_ will be picked up as EUnit test cases.

Erlang.mk will automatically pick up tests found in any of @@ -58,20 +58,20 @@ compiled.

-ifdef(TEST).
 %% Insert tests here.
 
 -endif.

Erlang.mk will automatically recompile your code when you -perform a normal build after running tests, and vice versa.

16.2. Configuration

The EUNIT_OPTS variable allows you to specify additional +perform a normal build after running tests, and vice versa.

17.2. Configuration

The EUNIT_OPTS variable allows you to specify additional EUnit options. Options are documented in the EUnit manual. At the time of writing, the only available option is verbose:

EUNIT_OPTS = verbose

The EUNIT_ERL_OPTS variable allows you to specify options to be passed to erl when running EUnit tests. For example, -you can load the vm.args and sys.config files:

EUNIT_ERL_OPTS = -args_file rel/vm.args -config rel/sys.config

16.3. Usage

To run all tests (including EUnit):

$ make tests

To run all tests and static checks (including EUnit):

$ make check

You can also run EUnit separately:

$ make eunit

EUnit will be quiet by default, only outputting errors. +you can load the vm.args and sys.config files:

EUNIT_ERL_OPTS = -args_file rel/vm.args -config rel/sys.config

17.3. Usage

To run all tests (including EUnit):

$ make tests

To run all tests and static checks (including EUnit):

$ make check

You can also run EUnit separately:

$ make eunit

EUnit will be quiet by default, only outputting errors. You can easily make it verbose for a single invocation:

$ make eunit EUNIT_OPTS=verbose

Erlang.mk allows you to run all tests from a specific module, or a specific test case from that module, using the variable t.

For example, to run all tests from the cow_http_hd module (instead of all tests from the entire project), one could write:

$ make eunit t=cow_http_hd

Similarly, to run a specific test case:

$ make eunit t=cow_http_hd:parse_accept_test_

To do the same against a multi-application repository, you can use the -C option:

$ make -C apps/my_app eunit t=my_module:hello_test

Note that this also applies to dependencies. From Cowboy, -you can run the following directly:

$ make -C deps/cowlib eunit t=cow_http_hd

Finally, code coverage -Chapter 18, Code coverage is available, +you can run the following directly:

$ make -C deps/cowlib eunit t=cow_http_hd

Finally, code coverage +Chapter 19, Code coverage is available, but covered in its own chapter.

-- cgit v1.2.3