W0008 - Unreachable Test
Error
-module(my_SUITE).
-export([all/0]).
-export([a/1, b/1]).
all() -> [a].
a(_Config) ->
ok.
b(_Config) ->
%% ^ warning: Unreachable test (b/1)
ok.
Explanation
The error message is indicating that the b
test case is not reachable by the Common Test testing framework and that it won't be executed by the testing framework.
In Common Test, test cases are auto-discovered by the framework via the all/0
and groups/1
function.
A function is deemed an unreachable test if:
- the function belongs to a module name ending with
_SUITE
- the function has arity
1
- the function is exported
- the function is not a Common Test callback function (i.e.
init_per_suite/1
,end_per_suite/1
orgroup/1
) - the function is not a callback implementation of an included behaviour
- the function is not reachable via the
all/0
andgroup/0
functions and it is therefore not executed by the Erlang Common Test framework.
In the above snippet, the b/1
function falls into that category since all of the above apply.
To fix this warning you should either remove the test cases (if not necessary any longer) or make it reachable via the all/0
function.
Sometimes it is intentional to have test cases which are defined but not running (e.g. they are occasionally run manually). In such case you can silent the warning by using an ELP ignore annotation.