Actionable coverage report with your test results.
1 test, 0 failures
The following files are missing coverage:
lib/a.ex 0.00% < 100.00% A
lib/a.ex:2
SpryCov total coverage: 0.00%
- Only generate coverage report if all the tests pass
- Only display files with less coverage then the configured threshold
- See just the files and lines that are missing coverage
- Display filtered results when running the test for a specific file or folder
mix test --cover test/lib/a_test.exs
display only coverage forlib/a.ex
mix test --cover test/lib/sub/
display only coverage for files inlib/sub/
- Don't report
defstruct
as not covered
Add spry_cov
to your list of dependencies in mix.exs
:
def deps do
[
{:spry_cov, "~> 0.3.1", only: [:test]},
]
end
Configure the project in mix.exs
:
def project() do
[
...
test_coverage: [tool: SpryCov],
...
]
end
Some of the default mix test options are compatible with SpryCov
Run mix test --cover
SpryCov will output all files with that don't meet the threshold with the lines not covered.
It will get very "noisy" in projects with many coverage gaps, we can workaround by using grep
mix test --cover | grep lib/a.ex
When running tests for only a few files and/or directories SpryCov will display the coverage for only those files and/or directories, there is no need for using grep
.
mix test --cover test/a_test.exs
Be careful because only the code being tested by those tests is going to be reported
Copyright (c) 2022, Tiago Moraes.
SpryCov source code is released under Apache 2 License.