Set name to DocTest tests

Hi,

I’m wondering if there is some way to put some custom / detailed name to the tests using the DocTest, in order to be showed on the console when I run “mix test --trace”.

I mixed 2 DocTests and 1 ExUnit to show the diff on the output:

$ mix test --trace

FooTest [test/foo_test.exs]

  • doctest Foo.say_hello/0 (2) (0.00ms) [L#3]
  • test return default greeting (0.00ms) [L#5]
  • doctest Foo.analyse/0 (1) (0.00ms) [L#3]

Finished in 0.03 seconds (0.00s async, 0.03s sync)
2 doctests, 1 test, 0 failures

Randomized with seed 321499

I’ve red the documentation but couldn’t find anything.

Thanks!

I’ve read the source code. The answer is: No can’t do.

# a = arity
# f = function
# m = module
# n = accumulating number
defp test_name(%{fun_arity: :moduledoc}, m, n) do
    "module #{inspect(m)} (#{n})"
  end

  defp test_name(%{fun_arity: {f, a}}, m, n) do
    "#{inspect(m)}.#{f}/#{a} (#{n})"
  end

source

2 Likes

Thanks Bart, looks like a good opportunity for PR? mhhh…