Consider the following code:

setup do
%{a: 1}
end

test "test", %{b: b} do
IO.inspect(b)
end

if we run the test, then it fails with the following error:
  1) test test (SandboxTest)
     test/sandbox_test.exs:8
     ** (FunctionClauseError) no function clause matching in 
SandboxTest."test test"/1

     The following arguments were given to SandboxTest."test test"/1:
     
         # 1
         %{a: 1, async: false, case: SandboxTest, describe: nil, 
describe_line: nil, file: 
"/home/artur/projects/sandbox/test/sandbox_test.exs", line: 8, module: 
SandboxTest, registered: %{}, test: :"test test", test_type: :test}
     
     code: test "test", %{b: b} do
     stacktrace:
       test/sandbox_test.exs:8: (test)


A way better error reporting is present if the test uses assert macro:

setup do
%{a: 1}
end

test "test", context do
assert %{b: b} = context
IO.inspect(b)
end

Error:
  1) test test (SandboxTest)
     test/sandbox_test.exs:9
     match (=) failed
     code:  assert %{b: b} = context
     left:  %{b: b}
     right: %{
              a: 1,
              async: false,
              case: SandboxTest,
              describe: nil,
              describe_line: nil,
              file: "/home/artur/projects/sandbox/test/sandbox_test.exs",
              line: 9,
              module: SandboxTest,
              registered: %{},
              test: :"test test",
              test_type: :test
            }
     stacktrace:
       test/sandbox_test.exs:10: (test)

It would be great if something similar is reported for the first code 
snippet.

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/a57c406e-6410-4f86-b3af-4422f8b266ben%40googlegroups.com.

Reply via email to