https://github.com/JuliaTesting/TestEnv.jl is the only reproducible way I have found. Not sure who originally created it, but I think it was another beautiful package from @oxinabox
- Create your normal package
Project.toml
file, no manifest checked into git - Create a
/test/Project.toml
file, again best not to check a manifest in and to use thecompat
as required, but less of an issue there, - Do a
] add TestEnv
to the global environment. Hopefully vscode even add/load testenv automatically at some point in the future. - Otherwise, keep your global environment clean (e.g. Revise, PkgBenchmark, BenchmarkTools, TestEnv but not much else) usually works best. I keep the package I am working on out of it, but probably other ways work
Just to be clear: at no point do you need to add your package to theglobal environment or manually make any temp project file, and you definetely don’t want to put test-only dependencies in the global environment,
Then to use this:
- Start vscode in your packages folder so it starts activated.
- To run the unit tests fully, you could just do the classic
] test
and it uses thetest/Project.toml
- To work interactively, given that your package is activated just go
using TestEnv; TestEnv.activate()
when you start up the REPL,
This creates, activates, and instantiates a temporary manifest that emulates what ] test
would do. Fully reproducible.
Then you can just use vscode as you normally would, executing the unit tests line by line, modify the package functions and then <shift-enter>
or using Revise, etc. Seamless.