josephwilk / amrita

A polite, well mannered and thoroughly upstanding testing framework for Elixir
200 stars 28 forks source link

Exception on failing test #120

Open houshuang opened 9 years ago

houshuang commented 9 years ago

Amrita works great on my passing tests, but on my first failing test, it creates an exception, and does not show me LHS and RHS, as ExUnit does.

Here is my test

fact "string and int", do: req("<param><value><string>hi</string></value></param><param><value><int>2</int></value></param>") |> {:ok, ["hi", 2]}

and here is the output

1) test string and int (XmlrpcTest)
 test/xmlrpc_test.exs:21
 ** (Amrita.FactError) Expected:
      {:ok, [2, "hi"]} |> test string and int
 stacktrace:
   lib/amrita/message.ex:10: Amrita.Message.fail/3
   test/xmlrpc_test.exs:21
houshuang commented 9 years ago

I monkey-patched fact-error.ex like this

-      "     #{Amrita.FactError.actual_result(exception)} |> #{Amrita.FactError.full_checker(exception)}" 
+      "     #{Amrita.FactError.actual_result(exception)} |> #{exception.expected}"

and now it gives the desired output

1) test string and int (XmlrpcTest)
 test/xmlrpc_test.exs:22
 ** (Amrita.FactError) Expected:
      {:ok, [2, "hi"]} |> {:ok, ["hi", 2]}
 stacktrace:
   lib/amrita/message.ex:10: Amrita.Message.fail/3
   test/xmlrpc_test.exs:22

I don't really need the whole stack-trace below, but otherwise it's working great. Love the compact format.