首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用hound获取我文件中测试的状态?

如何使用hound获取我文件中测试的状态?
EN

Stack Overflow用户
提问于 2019-09-28 04:55:55
回答 1查看 63关注 0票数 1

ExUnit提供了一些获取测试结果的方法。我不知道如何使用https://hexdocs.pm/ex_unit/ExUnit.Test.htmlhttps://hexdocs.pm/ex_unit/ExUnit.Formatter.html

我在一个文件中有多个测试。如何在最后生成结果,如Test name和Status?

我正在用猎犬写测试。提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2019-10-01 15:09:36

首先,可以使用ExUnit.after_suite/1来实现这一目的。最好的调优可能是引入您自己的格式化程序,并在调用ExUnit.start()之前将其传递给ExUnit.configure/1。有点像下面的(根据你的需要进行调整)。

代码语言:javascript
复制
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()
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58141243

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档