# Unexpected Results for Code Coverage with Julia Tests

**URL:** <https://discourse.julialang.org/t/unexpected-results-for-code-coverage-with-julia-tests/119195>\
**Category:** Tooling\
**Tags:** testing, macros, coverage\
**Created:** [September 8, 2024, 6:04pm UTC](https://discourse.julialang.org/t/unexpected-results-for-code-coverage-with-julia-tests/119195 "2024-09-08T18:04:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![janneshb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/janneshb/32/36035_2.png) [@janneshb](https://discourse.julialang.org/u/janneshb)\
**Post date:** [September 8, 2024, 6:04pm UTC](https://discourse.julialang.org/t/unexpected-results-for-code-coverage-with-julia-tests/119195/1 "2024-09-08T18:04:25Z")

</div>

Hi,

I’ve written a bunch of unit tests for my Julia package that are run by a GitHub action and uploaded to [codecov.io](http://codecov.io).  
However, lines marked as “uncovered” seem to be wrong at a few spots.

Especially, when macros are called form within macros they are not detected as “covered”.

Here is a minimal example:

```julia
macro some_macro(x)
    quote
        y = $(esc(x))
        if y <= 0
           @call_leq_zero y
        else
           @call_geq_zero y
        end
    end
end

```

If I run `@some_macro` from within a unit test, the lines `@call_leq_zero` and `@call_geq_zero` are not marked as covered.

Does anyone have experienced the same or know why this problem occurs?

Thanks!  
Best,  
Jannes

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [October 18, 2024, 1:41am UTC](https://discourse.julialang.org/t/unexpected-results-for-code-coverage-with-julia-tests/119195/2 "2024-10-18T01:41:00Z")

</div>

I haven’t looked into your specific example, but there’s lots of known issues regarding code coverage. Currently it’s just not very reliable. Github issues labeled as [code coverage](https://github.com/JuliaLang/julia/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22code%20coverage%22).

---

<div class="post-metadata">

**Author:** ![janneshb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/janneshb/32/36035_2.png) [@janneshb](https://discourse.julialang.org/u/janneshb)\
**Post date:** [October 18, 2024, 12:50pm UTC](https://discourse.julialang.org/t/unexpected-results-for-code-coverage-with-julia-tests/119195/3 "2024-10-18T12:50:23Z")

</div>

Yeah, I decided to just live with the 97% coverage that I get without covering the macros…  
I hope this will be solved in the future
