We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Improving code coverage with AI agents
almirsarajcic
Created
Did you know AI agents can even help you with code coverage? Maybe you wanted to figure out all the scenarios you haven’t covered in your tests. That’s one of my favorite use cases for them, relieving me from repetitive tasks.
When you’re not sure which files you haven’t covered yet, you’d probably reach out for mix test --cover
and look for files with 0.0% coverage. But what to do when you’ve maybe covered only half of a module? Or maybe you’re at ~95% and can’t think of a way to find those few lines that you haven’t covered yet?
In the past, to solve that, I’d use mix coveralls.html
from https://github.com/parroty/excoveralls and open the resulting file cover/excoveralls.html
in the browser to see exactly which lines haven’t been executed during the test run.
But in times when AI agents are capable of creating whole apps, it seems a waste to look for this manually. I tried using that command, but AI agents struggle finding valuable information from that file (for now).
Fortunately, excoveralls comes out with a task writing output in a format perfect for this.
mix coveralls.json
You can even focus on one test module at a time, as with mix test
command:
mix coveralls.json test/elixir_drops_web/live/user_drop_live_test.exs
You can add something like this to your Cursor rules:
To check code coverage, run `mix coveralls.json` and then read the file `cover/excoveralls.json`.
We’ve already included this in our Cursor rules.
Copy link
copied to clipboard