小编Tom*_*ear的帖子

在测试时撬

我是Elixir的新手,但它有很多乐趣!

我来自Ruby世界,所以开始看起来比喻.并且存在调试工具pry.使用binding.pry我可以中断任何会话.我在Elixir找到了类似的东西 - IEx.pry.但是当我通过测试时,它不起作用ExUnit.

问题 - 是否可以中断测试会话并使用当前环境运行iex?

testing elixir iex

51
推荐指数
2
解决办法
5332
查看次数

在 elixir 中的每个测试之间设置/拆卸 det 表?

我们试图在一个完全干净的 dets 环境中运行每个测试,每个测试负责自己的设置。我们遇到了无法在测试之间完全删除目录的问题。

我们如何重置dets?我们是否错误地认为吹走整个目录并重新启动应用程序就足够了?在运行之间删除所有记录是否更好?

认为:

  • async: true 未设置任何测试。
  • dets 是必须的
  • 大多数回答的代码应该(如果可能的话)在 elixir 中,而不是在 erlang 中。

示例代码:

setup do
  #clean up anything that wasn't already clean (failed teardown, etc)
  TestSetup.teardown_dets(:myappatom, "dets")

  on_exit fn ->
    TestSetup.teardown_dets(:myappatom, "dets")
    Application.ensure_all_started(:myappatom)
    Process.sleep(300)
  end
end
Run Code Online (Sandbox Code Playgroud)

和拆卸功能的胆量......

def teardown_dets(application_atom, directory) when is_bitstring(directory) do
  teardown_dets(application_atom, [directory])
end
def teardown_dets(application_atom, directories)
  when is_atom(application_atom) and is_list(directories)
do
  #stop the applications completely
  Application.stop(application_atom)

  #blow away all dets while the application is stopped
  try do
    directories
    |> Enum.map(&File.rm_rf(&1))
  rescue
    error …
Run Code Online (Sandbox Code Playgroud)

elixir dets ex-unit

6
推荐指数
0
解决办法
696
查看次数

标签 统计

elixir ×2

dets ×1

ex-unit ×1

iex ×1

testing ×1