numso

numso

Hi all!

I noticed something odd while testing one of my LiveViews today. I wrote a test for one of the handle_event/3 function clauses. Made the test pass. Verified that the assigns were getting set correctly. Then discovered that code coverage wasn’t marking that code as having been run. I added an IO.inspect/2, saw the log in my test output, but code coverage still says that IO.inspect line was never run.

I was able to make a very minimal reproduction in a brand new mix new project:

elixir 1.17.3-otp-27
erlang 27.1

defmodule CoverageBug do
  def hello do
    check("target", nil)
    :world
  end

  def check("one", _) do
    nil
  end

  def check("two", _) do
    nil
  end

  def check(_, %{some_match: :three}) do
    nil
  end

  def check("four", _) do
    nil
  end

  def check("target", _) do
    IO.inspect("This line is run but not covered")
    nil
  end
end

defmodule CoverageBugTest do
  use ExUnit.Case

  test "greets the world" do
    assert CoverageBug.hello() == :world
  end
end

When running mix test --cover, you’ll see the IO.inspect line logged out in the test output. But it won’t show up as covered in the test coverage report. If you delete any of those first 4 check function clauses, then the IO.inspect in the 5th clause will start being reported as covered. Has anyone experienced anything like this? Am I missing something obvious?

Showing Posts 1 to 2

numso

numso OP

I ended up trying this with a different version of erlang and it worked:

elixir 1.17.3-otp-26
erlang 26.2.5.3

So looks like this was a regression in the latest erlang major release.

zorn

zorn

Thanks for sharing. I don’t personally look at these numbers, but I know we have CI tools at work that do – and they output curious results, so this might be related.

Appriciate your signal.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Damirados
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
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews