简体   繁体   中英

How can I configure applications only for mix-test?

Suppose we have a module A that requires a configuration. When we consume A, it's just OK to put [applications: [:a]] in mix.exs and put config :a, [] in config/config.exs in our project.

But when we're developers of the module A, how/when can we configure :a on a command of mix test in the A directory? Can we do that in test/test_helpers.exs or somewhere?

You might want to derive the behaviour from Phoenix . What it does, is basically three additional files in config directory, named dev.exs , prod.exs and test.exs and the following clause in config.exs :

import_config "#{Mix.env}.exs"

Since mix sets the Mix.env appropriately, the respective configuration will be loaded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM