Test coverage on has_one macros in views

I have noticed I’m consistently missing test coverage on has_one macros in my views. I know for certain that these are being executed properly because I’m seeing the relationships rendered in the output of my APIs. I’ve tried the built in test coverage tool and excoveralls and seen the same issue with both.

What am I doing wrong? Is this an issue with the coverage tools or do I need to write a specific test to cover this macro properly?

Here’s an example of a has_one macro that isn’t getting coverage
has_one :teacher, links: [related: "/students/:id/teacher"]

has_one comes from JaSerializer btw

Thanks!

Coverage in elixir is reported using erlangs cover module, therefore it’s kinda unaware of macros. So to know why this line is marked as untested you’ll need to look at what the macro is replaced with at compile time.

1 Like

Good to know! Thanks for the response.