例如,我使用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/