Test of coverage in custom exception

I wanted a light where I might be wrong in implementing an Exception with your coverage test.

Lib used is the excoveralls.

Example:

Exception in directory lib

defmodule ExceptionTes
  defexception message: "new exception"
end

Test in directory test

defmodule MyappWeb.ExceptionTesTest do
	use ExUnit.Case, async: true

	def my_fn do
	  raise ExceptionTes
	end

	test "test exception" do
	  assert_raise ExceptionTes, "new exception" , fn ->
		my_fn()
	  end
	end

end

COV FILE LINES RELEVANT MISSED
0.0% lib/exceptions/expection_tes.ex 3 0 0

What I did wrong to not have coverage on this file.

1 Like

Hi @jackbpaiva I have a similar issue.
I have created a custom exception and written tests similar to yours, however the coverage doesn’t seems to cover the exception.
I know it’s been a while this question was asked but I was wondering if you did find a solution to this?
Thanks

1 Like