elixir - 测试套件上是否需要手动启动 OTP 应用程序

标签 elixir erlang-otp

例如,我使用HTTPotion

它在 mix.exs 中的列出如下:

  def application do
    [ applications: [:httpotion]
  end

我需要在 test_helper 或设置宏中提供 HTTPotion.start() 吗?

有时我的测试会失败,因为 HTTPotion 没有启动,所以我在 helper.txt 中添加了这一行。但是,一段时间后它可能会再次失败,所以我需要删除它,编译并再次添加它,再次编译,然后它再次工作。

我不明白问题是出在这个领域还是其他地方。

最佳答案

简短回答:不,你不需要。

当你想在 iex 中运行 HTTPotion 时,每次之前你都必须使用这句话 HTTPotion.start,但这就是使用 mix 的全部意义 - 它会在背景。

请阅读this请注意,特别是这句话:

Mix normally starts the whole hierarchy of applications defined in our project’s mix.exs file and it does the same for all dependencies if they depend on other applications.

.

关于elixir - 测试套件上是否需要手动启动 OTP 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38463565/

相关文章:

elixir - 离线构建十六进制注册表文件

erlang - Erlang/OTP持续部署简介

elixir - 如何验证 Elixir 中的网址?

elixir - 为什么[头| tail ] 语法在用作 arg 时与 Elixir 中的单个元素数组匹配吗?

erlang - 使用 gen_server 封装一个 mnesia 表?

erlang - 我应该为此使用什么 OTP 行为?

linux - 如何将 child 添加到 erlang supervisor?

concurrency - Elixir - 受监督的进程似乎会阻止程序执行

elixir - 我如何提取 Elixir Map 中的值

python - 在 Elixir 中寻求 "send+more=money"的惯用、优雅的解决方案