`mix test --cover` generates `Inspect.XXX.XXX` modules which repo does not have

Hi folks,

When we run mix test --cover, we see some modules which starts with Inspect.XXX.XXX at cover results.

mix test --cover

Output

Generating cover results ...

Percentage | Module
-----------|--------------------------
     0.00% | Inspect.Datalayer.Account
     0.00% | Inspect.Datalayer.User
     0.00% | Datalayer.Account
     0.00% | Datalayer.User
     0.00% | Datalayer.Number
  • Our system has Datalayer.Account, Datalayer.User, etc modules but has not Inspect.Datalayer.Account, Inspect.Datalayer.User modules.
  • We have more than 20 modules, but only 5 of them generate Inspect.XXX.XXX module when we run mix test --cover.
  • All these modules has use Ecto.Schema behavior.

My questions are

  • To understand what is happening here?
  • Any suggestion? Should I exclude these modules (Inspect.XXX.XXX) from test? etc.

Regards.

To answer your first question: Inspect is an Elixir protocol that is implemented for some of your schema modules. Most likely because you have redact: true set on some fields. Ecto derives a custom Inspect implementation in that case.

In general: for each protocol Proto that is implemented for a module Mod, there will be an implementation module called Proto.Mod.

As for testing or excluding the modules, maybe somebody else has a recommendation. (I‘m not tracking test coverage in any of my projects) You could write tests that check if the schema fields are redacted when inspected - at that point you’d be testing Ecto itself though :man_shrugging:

6 Likes

Dear @awerment,

Thank you for your reply. I really understand what is going on.

Regards.

1 Like