# Code coverage issue with methods that return a constant bool

**URL:** <https://discourse.julialang.org/t/code-coverage-issue-with-methods-that-return-a-constant-bool/1088>\
**Category:** General Usage\
**Tags:** bug, coverage\
**Created:** [December 21, 2016, 12:14pm UTC](https://discourse.julialang.org/t/code-coverage-issue-with-methods-that-return-a-constant-bool/1088 "2016-12-21T12:14:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evizero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evizero/32/10118_2.png) [@Evizero](https://discourse.julialang.org/u/Evizero)\
**Post date:** [December 21, 2016, 12:14pm UTC](https://discourse.julialang.org/t/code-coverage-issue-with-methods-that-return-a-constant-bool/1088/1 "2016-12-21T12:14:40Z")

</div>

I am observing a (to me) strange issue concerning code coverage. The result of `Pkg.test(...; coverage=true)` tells me that a lot of methods are never called while I know they were.

The methods in question all have a very similar look (they are used to represent a property of the type) e.g.:

```julia
myfunc(::MyType) = true

```

calling these methods from the tests simply does not seem to count to coverage. In my desperation I tried things like using `@noinline`, as well as calling the methods in tricky ways with something like:

```julia
@test myfunc(rand() <= 1 ? MyType() : 0) == true

```

all to no avail. According to the .cov files, `myfunc` is never called.

I created a repository with a minimal example that show my confusion a little clearer hopefully. It also includes the .cov fil (tests all pass)

[https://github.com/Evizero/CoverageIssue.jl](https://github.com/Evizero/CoverageIssue.jl)

Any idea what is going on? Am I doing something wrong here?

EDIT: Also note that I think this behaviour is rather new (I discovered it today when looking at the results of Travis and Coveralls), I could immediately reproduce it locally even though I don’t remember updating anything since last it worked.

```julia
Julia Version 0.5.0
Commit 3c9d753 (2016-09-19 18:14 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-1650 v3 @ 3.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (NO_LAPACK NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: liblapack.so.3
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)

```

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [December 21, 2016, 1:34pm UTC](https://discourse.julialang.org/t/code-coverage-issue-with-methods-that-return-a-constant-bool/1088/2 "2016-12-21T13:34:46Z")

</div>

Fixed on master…
