i-n-g-m-a-r
How to improve phoenix test coverage?
$ mix test --cover
......
Generating cover results ...
Percentage | Module
-----------|--------------------------
0.00% | DemoWeb.Layouts
0.00% | DemoWeb.PageHTML
16.67% | DemoWeb.CoreComponents
25.00% | Demo.DataCase
50.00% | Demo.Repo
50.00% | DemoWeb.ErrorHTML
75.00% | Demo.Application
75.00% | DemoWeb.Router
80.00% | DemoWeb.Telemetry
100.00% | Demo
100.00% | Demo.Mailer
100.00% | DemoWeb
100.00% | DemoWeb.ConnCase
100.00% | DemoWeb.Endpoint
100.00% | DemoWeb.ErrorJSON
100.00% | DemoWeb.Gettext
100.00% | DemoWeb.PageController
-----------|--------------------------
27.41% | Total
Coverage test failed, threshold not met:
Coverage: 27.41%
Threshold: 90.00%
Generated HTML coverage results in "cover" directory
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
Hi @i-n-g-m-a-r I’m confused you’re asking a question but then also linking to a blog post that answers your question. Can you elaborate as to what you’re looking for?
dimitarvp
Most, if not all, of these files are pretty safe to put in a ignore clause for code coverage. I mean how would you meaningfully have a 100% test coverage of a telemetry module that’s mostly generated code?
i-n-g-m-a-r
Hi Ben,
I’m looking for actual test coverage.
With regard to the (ignore_modules) answer this would feel acceptable:
To exclude every single view does not feel acceptable.
I don’t know how to make a view pass any test.
With regard to CoreComponents it would be nice to have a working example.
Then we could update the tests after making changes to (modules using) CoreComponents.
While on the topic of testing phoenix applications,
I find myself putting this kind of not very pretty code into ConnCase:
In order to test all kinds of scenario’s involving sessions / cookies.
Probably this kind of code shouldn’t be necessary.
i-n-g-m-a-r
The generated code could be tested / covered ?
dimitarvp
Why should it? And how do you test the generated telemetry module, for example? It serves as a callback / handler that’s registered elsewhere; not in your application logic.
D4no0
What do you mean, what about 100% coverage
?
BTW totally agree, this is definitely not the responsibility of the developer to test generated modules, even if they are theoretically now part of your application.
benwilson512
Taking a bit of a step back, I wonder if there is perhaps gaps in how the test coverage is measured? If he’s got basic tests to render say the front page you’d expect that to run the
DemoWeb.PageHTMLandLayoutsmodules.D4no0
To be fair I don’t understand even to this day what this metric achieves, the fact that tests execute 100% of your code, doesn’t mean that the tests won’t miss a bug.
In the world of agile development, where we make software that evolves over time, having 100% coverage is like shooting yourself in the leg, a lot of effort to write tests, tests are brittle because they cover all implementation details, a lot of effort to change code and rewrite tests.
I even worked at a company where they implemented mutation testing, where it would be literally impossible to change a line of code without a couple of tests failing.
i-n-g-m-a-r
Hi Ben,
This is a regular pattern:
Where ThingController is tested using (also) lots of different ConnCase calls (get, post, etc).
i-n-g-m-a-r
Personally I would trust phoenix code to be well tested.
So most of the time I’m more rigorous regarding my own code.
Sometimes though I will collaborate with or work for people that demand good coverage.
Starting with near 100% would be nice.