How to test plot recipes?

Plot recipes can reduce the test coverage considerably. For example, my coverage is currently at 76% and a big part of the remaining 24% is due to a plot recipe: Codecov

How should I go about testing plot recipes? Is there any way to design meaningful tests without human interaction?

3 Likes

https://github.com/JuliaPlots/VisualRegressionTests.jl

Or you could just call RecipesBase.apply_recipe with arguments that will
dispatch to your recipe.

4 Likes

@tbreloff I really like the idea of VisualRegressionTests.jl, but apparently I am missing something about how it works. As you can see, the recipe itself is not covered by the tests that I wrote: Codecov

It’s not clear to me how to use this way of testing. Should the first argument to RecipesBase.apply_recipe be an empty dictionary Dict{Symbol,Any}()?

As a side comment, this coverage issue doesn’t exist anymore. It was fixed somewhere in Plots.jl or VisualRegressionTests.jl.

For the record, this is what I ended up doing for testing plot recipes Measurements.jl:

Note that this is using some internals of RecipesBase.jl, so use it at your own risk :slightly_smiling_face:

Sorry for necroposting, but I see that this thread comes is among first results when searching for plotting tests in Julia, so I thought it could be useful to point out this option.

8 Likes