Recommended vscode workflow to run a module's tests interactively

Hi, I’m trying to run my module’s test line-by-line in vscode (as I used to when I had all my code in 1 file), so I can experiment with the REPL, and see the results of plots.

More specifically, I opened runtests.jl:

(BTW I verified that these tests run with ] test.)

But I bump into 2 problems:

  1. on the first line, using RayTracingWeekend, I get an ArgumentError: Package RayTracingWeekend not found in current path. I’m not sure how to best fix this issue, i.e. allow using the parent module.

  1. When I try to run a single line within a test, using Shift-Enter, it runs the whole test. CTRL-Enter too. How can I run line-by-line, e.g. to see the plot of gradient(20,10) in the final line of that test?

Thank you very much!

Regarding the first part’ For testing there is the great TestEnv package which should at least fix missing dependencies problems. So you activate your general environment of that package and then invoke the TestEnv activate function.

1 Like

Remove the test from there. (Open the main project folder directly, to be in the environment of the project)

And add the test-only dependencies to the “extras” section of Project.toml

Thanks, I tried that too (sorry, should have mentioned it) and it made no difference to the two problems I described…

Thanks! I just tried TestEnv, it allows me to activate the module’s test environment, but when I try to run using RayTracingWeekend with Shift-Enter I still get the same error message… i.e. I can’t use my own module’s functions in its tests when I run interactively…

It now looks like problem #1 may be a bug specific to the previous version of vscode (and possibly the newer one too - I didn’t try it since it has a different bug ). I tried vscode-insiders 1.64.0 with the Julia-insiders plug-in, and I’m able to run using RayTracingWeekend without problem.

As for problem #2… I finally noticed that there’s an issue for that:

My work-around for now is to manually comment-out the @testset and its end, everytime I want to run the test… annoying and error-prone…