patch icon indicating copy to clipboard operation
patch copied to clipboard

Patch seems to break (or is ignored by) testcoverage tooling?

Open DGollings opened this issue 1 year ago • 4 comments

First off, I really liked the API/implementation of Patch. Really enjoy using it so thanks for making it

But whilst experimenting with some code coverage tooling (mix test --cover) noticed that code that uses Patch.patch disappears from the reports.

So decided to clone this repo and noticed the same. Picked a test at random that uses patch(), refute_any_call_test.exs

❯ grep 'patch(' ./test/user/refute_any_call_test.exs
      patch(RefuteAnyCall, :function_with_multiple_arities, :patched)
      (..)
      patch(RefuteAnyCall, :other_function, :patched)
      patch(RefuteAnyCall, :function_with_multiple_arities, :patched)

but then:

mix test --cover 2>&1 | grep RefuteAny

outputs nothing, same for

grep RefuteAnyCall cover -r

which, seeing all the generated html files in cover/ seems unlikely

I assume this is known behaviour? I can imagine its a side-effect of how the 'super-powers' work but are you aware of a workaround or fix? Because its a bit ironic that the most well tested code in my codebase shows up as 0% or not at all :)

And a ps. Running the test directly mix test --cover ./test/user/refute_any_call_test.exs does show the User.Patch modules nearby but almost all of them as 0% coverage

DGollings avatar Sep 12 '24 19:09 DGollings