How can you guarantee that all the functions / branches / loops in your package has been tested?

Is there any automated testing method for a rather complicated package? Probably a macro that injects some logging commands to each function / if-else branch / for-loop and produce a statistical analysis of the coverage of a testing procedure? I know the macro @profile can record execution time, but how about coverage ?

Coverage is usually handled by continuous integration tools, e.g., codecov. You can setup you github repo with automatic hooks to codecov such that you get a warning if code coverage decreased by pulling a PR. You can even prevet a PR from being merged unless codecov returned the desired status.

You find more info at

3 Likes

Concerning the testing and coverage handled in Continuous Integration tools that @baggepinnen was referring to, you can have a look on this tutorial to learn how to applying it to Julia packages…

2 Likes

This is exactly what I wanted. Thanks !

The tutorial is very elaborate. Thank you very much!

However note that services like codecov only show you line code coverage, but tell you nothing about paths of the code: conditionals, loops, and other control flow statements can make the behaviour of a line very different if it’s hit from different places.

3 Likes