jjh42 / mock

Mocking library for Elixir language
MIT License
639 stars 81 forks source link

When assert_called we can see what was expected and what was captured #145

Open alexfilatov opened 4 months ago

alexfilatov commented 4 months ago

Just a small helped information to understand what was captured and what was expected in the assertion.

So error message will look like the following:

  1) test demo_function/2 (MyApp.ManagerTest)
     test/my_app/manager_test.exs:110
       Expected call but did not receive it. Calls which were captured:

     0. Elixir.MyApp.Sender.send_later(MyApp.MyWorker,["9030b86d-c502-4353-8d4a-3bf414eef5d8", "name-7"]) (returned {:ok, :enqueued}).

       Expected call: Elixir.MyApp.Sender.send_later(MyApp.MyWorker,["dc3230b4-f3a1-46fd-b109-e8124ab779f7", "name-7"])

     code: assert_called(
     stacktrace:
       test/my_app/manager_test.exs:123: (test)
alexfilatov commented 4 months ago

@jjh42 please let me know if that makes sense :)