Don Branson
Don Branson

Reputation: 13709

Is there a way to call application:set_env in an eunit test?

Is it possible in an eunit test to set an environment variable used in the code under test? This fails with **error:undef:

example_test() ->
  application:set_env(an_app, example_key, "value").

Edit:

There's not much to show for the error, but here's the full stack:

    env_request_handler_tests: a_test_ (example_test)...*failed*
in function application:set_env/3
  called as set_env(an_app,example_key,"value")
in call from env_request_handler_tests:'-a_test_/0-fun-2-'/1 (include/test_fixture.hrl, line 13)
**error:undef

Upvotes: 0

Views: 243

Answers (0)

Related Questions