MicroCoverage.jl

Code coverage generation for Julia, implemented in pure Julia
Author bcbi
Popularity
2 Stars
Updated Last
3 Years Ago
Started In
January 2020

MicroCoverage

Build Status Codecov Coveralls

MicroCoverage.jl is a code coverage tool for Julia, implemented in pure Julia.

Installation

julia> using Pkg; Pkg.add("MicroCoverage")

Example

Step 1: Create a file named foo.jl with the following contents:

function foo(x)
    if x == 1 || x == 100
        return "hello"
    else
        return "goodbye"
    end
end

Step 2: Create a file named test_foo.jl with the following contents:

using Test

@test foo(1) == "hello"

Step 3: Open julia and run the following commands:

julia> using MicroCoverage

julia> MicroCoverage.start("foo.jl")

julia> include("foo.jl")

julia> include("test_foo.jl")

julia> MicroCoverage.stop()

When you run MicroCoverage.stop(), MicroCoverage will create a file named foo.jl.microcov with the following contents:

[1,1,1]                 function foo(x)
[1,0,1,0,1]                 if x == 1 || x == 100
[1]                             return "hello"
-                           else
[0]                             return "goodbye"
-                           end
-                       end
-

Acknowledgements

  • This work was supported in part by National Institutes of Health grants U54GM115677, R01LM011963, and R25MH116440. The content is solely the responsibility of the authors and does not necessarily represent the official views of the National Institutes of Health.

Related Work

  1. https://github.com/StephenVavasis/microcoverage