ExUnit提供了一些获取测试结果的方法。我不知道如何使用https://hexdocs.pm/ex_unit/ExUnit.Test.html和https://hexdocs.pm/ex_unit/ExUnit.Formatter.html。
我在一个文件中有多个测试。如何在最后生成结果,如Test name和Status?
我正在用猎犬写测试。提前谢谢。
发布于 2019-10-01 15:09:36
首先,可以使用ExUnit.after_suite/1来实现这一目的。最好的调优可能是引入您自己的格式化程序,并在调用ExUnit.start()之前将其传递给ExUnit.configure/1。有点像下面的(根据你的需要进行调整)。
defmodule MyApp.CLIFormatter do
@moduledoc false
use GenServer
def init(opts), do: {:ok, opts}
def handle_cast({:suite_started, _opts}, config) do
IO.puts("Started")
{:noreply, config}
end
def handle_cast({:suite_finished, run_us, load_us}, config) do
IO.inspect(
{{:suite_finished, run_us, load_us}, config},
label: "Finished")
{:noreply, config}
end
def handle_cast(_, config), do: {:noreply, config}
end
ExUnit.configure(formatters: [ExUnit.CLIFormatter, MyApp.CLIFormatter])
ExUnit.start()https://stackoverflow.com/questions/58141243
复制相似问题