Testing a package with runtests.jl does not generate graphical outputs

My students and I have been developing a package in Julia, and under the test directory, we have a file runtests.jl as the other packages. In it, we try to run some plotting functions to show some graphics (via Plots.jl), but when I run this via ] test MyPackage, say, the test passes without any errors, but it does not generate any graphical plots. Is this an intended design for testing packages via runtests.jl? In fact, when I tried the standard graphics packages, e.g., ] test GR, ] test Plots, etc., the tests passed without any errors, but no graphical outputs were generated either.

Hard to say more without a minimal working example.

Try capturing the output and then calling display:

julia> p = plot(rand(5));    # no graphical output produced

julia> typeof(p)

julia> display(p)

When you don’t use the semicolon, the show/display method is called implicitly, which is why you expect to see graphical output.

If you’re running your code with julia plottingscript.jl, the other potential cause would be the script finishing before the window appears. Tricks such as described here may be useful, though the signal_connect would have to be replaced by whatever needed to monitor for window closure.

Hi, Tim.
Thanks for your advice. I have tried both methods you mentioned. However, the image still can’t be displayed. The best I can get is one line of "Plot{Plots.GRBackend() n=1} " showing that one image variable was created.

Probably far too late, but I recently encountered the same problem when using the package PyPlot.jl when executing the tests in tests\runtests.jl of my project.

What worked for me was to call ion() before the first plot command.
After creating the plot, I used pause(5) to allow some time for inspecting the plot.
After that, I closed the plot and finally issued ioff().

@Nikos_Gianniotis ; thanks a lot for your suggestion. But have you tried these ion and ioff under Plots.jl’s pyplot() backend? I am not using PyPlot.jl directly. I always use Plots.jl with various backends.

Hi @BVPs. I’m afraid I only ever use PyPlot.jl and have no experience with other plotting packages. I understand that Plot.jl can use PyPlot.jl as a backend, but I have never even installed it. One hears good things about Plots.jl though…sorry!

In this situation I would probably have it save the images as png or pdf.