Julia Testing - gher-uliege/Documentation GitHub Wiki
Test coverage of Julia scripts
Required software
- the julia package 'Coverage'
Pkg.add("Coverage")
sudo apt install lcov
Analysis the test coverage
- Assume that we have a script
quadtree.jl
inside src
which includes some test code.
- Run the script with the julia option --code-coverage
- The generated
.cov
can be directly opened with a text editor and the numbers in the first column indicates how often a given line was executed.
julia --code-coverage -e 'include("src/quadtree.jl")'
- For a more graphical representation, convert the file in the lcov format.
julia -e 'using Coverage; LCOV.writefile("lcov.info", process_file("src/quadtree.jl"))'
- Produce a summary and generate a HTML report of the test coverage
lcov --summary lcov.info
genhtml -o res lcov.info
firefox res/index.html &
rm src/quadtree.jl.*.cov