Cannot fetch the app env in common test

Hi all,

I would like to use a custom config file for ct.

If I try to display application:get_all_env(myapp), it is however always empty.

I tried specifying the config file in 2 ways:

  1. In rebar.config as {ct, [{config, "config/test.config"}]}.
  2. From the cli as rebar3 ct --config config/test.config

I made a minimal project so it’s easy to reproduce, if you anyone would help: GitHub - carlotm/cte

Notes:

  1. I start the application in the suite like this: cte/test/cte_SUITE.erl at 80ed9ad168464ab052960c0d075aabd2e97ca6b8 · carlotm/cte · GitHub
  2. What I’m using to check if the env is picked up is erlang display, here: cte/src/cte_app.erl at 80ed9ad168464ab052960c0d075aabd2e97ca6b8 · carlotm/cte · GitHub

Cheers!

Have you started your app?

I…e. application:start(myapp). in init_per_suite, init_per_group or init_per_testcase or in the testcase it self.

I am using {ok, _} = application:ensure_all_started(cte), in the init_per_suite (see Notes 1. in the original post for a link to the specific line)

It should be: {ct_opts, [{sys_config, ["config/test.config"]}]}

Correct! Thanks.

For reference, it’s documented here.

Cheers!

1 Like