fireproofsocks
Test coverage for structs and mocks
I’m working on a umbrella app that relies on the built-in test coverage tools to generate reports, e.g
mix test --cover --export-coverage default
mix test.coverage
I’m noticing that modules that do nothing other than declare structs and mocked modules (mocked via mox) both show up as 0% coverage in the coverage report. For example:
defmodule Bar do
defstruct [:a, :b, :c]
end
Mox.defmock(FooMock, for: Foo)
earn both modules an entry in the report, e.g.
Percentage | Module
-----------|--------------------------
0.00% | Bar
0.00% | FooMock
-----------|--------------------------
0.00% | Total
Is the only way to ignore these types of modules from the final output to explicitly list them in the ignore_modules section, e.g.
def project do
[
# ...
test_coverage: [ignore_modules: [Bar, FooMock]]
]
end
There are reasons why we cannot currently use excoveralls or other tools for this (even though ExCoveralls doesn’t “mis-diagnose” these particular cases IIRC). Is there some other way to modify our report? Or is this report actually telling us something useful that I have overlooked?
Thanks for any insights!
First Post!
tjchambers
Last Post!
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









