Debugging with breakpoints in ExUnit

srikanthkyatham

Srikanth Kyatham

Posted on February 28, 2024

Debugging with breakpoints in ExUnit

Hi

The following is a demonstration on how to debug using debugger. Of course, IO.inspect works. Where it does not.

defmodule Math do
  def add(a, b) do
    a + b
  end
end
Enter fullscreen mode Exit fullscreen mode
defmodule MathTest do

  # timeout: :infinity is needed as the exunit timeouts around 3 seconds 
  @tag timeout: :infinity
  test ~c"test add" do
    :debugger.start()
    :int.ni(Math)
    # break_in take module, function, arity
    # module - Math
    # function - add
    # arity - 2 no of parameters
    :int.break_in(Math, :add, 2)
  end
end
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
srikanthkyatham
Srikanth Kyatham

Posted on February 28, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Debugging with breakpoints in ExUnit
elixir Debugging with breakpoints in ExUnit

February 28, 2024