# How to test plot recipes?

**URL:** https://discourse.julialang.org/t/how-to-test-plot-recipes/2648
**Category:** Visualization
**Tags:** question, testing, plotting, recipe
**Created:** [March 14, 2017, 1:55am UTC](https://discourse.julialang.org/t/how-to-test-plot-recipes/2648 "2017-03-14T01:55:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [March 14, 2017, 1:55am UTC](https://discourse.julialang.org/t/how-to-test-plot-recipes/2648/1 "2017-03-14T01:55:39Z")

</div>

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](https://codecov.io/gh/juliohm/ImageQuilting.jl/src/master/src/plot_recipes.jl)

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

---

<div class="post-metadata">

### Author: ![tbreloff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbreloff/32/68_2.png) [@tbreloff](https://discourse.julialang.org/u/tbreloff)
#### Post date: [March 14, 2017, 2:39am UTC](https://discourse.julialang.org/t/how-to-test-plot-recipes/2648/2 "2017-03-14T02:39:06Z")

</div>

[https://github.com/JuliaPlots/VisualRegressionTests.jl](https://github.com/JuliaPlots/VisualRegressionTests.jl)

Or you could just call RecipesBase.apply\_recipe with arguments that will  
dispatch to your recipe.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [March 24, 2017, 2:05am UTC](https://discourse.julialang.org/t/how-to-test-plot-recipes/2648/3 "2017-03-24T02:05:19Z")

</div>

@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](https://codecov.io/gh/juliohm/ImageQuilting.jl/src/master/src/plot_recipes.jl)

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [October 16, 2017, 12:33am UTC](https://discourse.julialang.org/t/how-to-test-plot-recipes/2648/4 "2017-10-16T00:33:31Z")

</div>

> [@tbreloff](#):
>
> Or you could just call RecipesBase.apply\_recipe with arguments that will  
> dispatch to your recipe.

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}()`?

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [October 16, 2017, 12:39am UTC](https://discourse.julialang.org/t/how-to-test-plot-recipes/2648/5 "2017-10-16T00:39:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [April 24, 2020, 3:29pm UTC](https://discourse.julialang.org/t/how-to-test-plot-recipes/2648/6 "2020-04-24T15:29:29Z")

</div>

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

> <https://github.com/JuliaPhysics/Measurements.jl/blob/2ef7fadf7c2644408cff555781b9c10adfca26f6/test/plots.jl>

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

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.
