Hello, could anybody point out some mistakes I am doing or give some guidance on why my function is undefined when running the common tests.
I have the following file /src/config_handler.erl
-module(config_handler).
-export([election_delay/0]).
election_delay() ->
application:get_env(elector, election_delay, 3000).
My test file is /test/config_handler_SUITE.erl
-module(config_handler_SUITE).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
-export([groups/0, all/0, init_per_group/2, end_per_group/2]).
-export([election_delay_test/1]).
groups() ->
[{config_handler_group, [], [election_delay_test]}].
all() ->
[{group, config_handler_group}].
init_per_group(_GroupName, Config) ->
Config.
end_per_group(_GroupName, _Config) ->
application:set_env(elector, election_delay, 3000).
election_delay_test(_Config) ->
application:set_env(elector, election_delay, 5000),
?assert(config_handler:election_delay() == 5000).
When running the test with: ct_run -dir test -logdir test_logs
I get:
=== === Reason: undefined function config_handler:election_delay/0
in function config_handler_SUITE:election_delay_test/1 (config_handler_SUITE.erl, line 21)
in call from test_server:ts_tc/3 (test_server.erl, line 1782)
in call from test_server:run_test_case_eval1/6 (test_server.erl, line 1291)
in call from test_server:run_test_case_eval/9 (test_server.erl, line 1223)
I am not sure why the function is undefined although it is defined and exported. Does anybody else have any ideas?
Thanks in advance I recently started coding in erlang so I might be doing some stupid mistakes that I am not aware of.