I’m very new to Julia, and I’ve been trying to get some unit tests up with TestItemRunner.jl. Following the recommended way to specify test dependencies (my account is too new to link, but this is following the Pkg.jl docs):
Project.toml:
name = "mvce"
uuid = "5c5c69df-07ce-4eec-9db9-de18ccd496a9"
authors = ["Peter Hill <peter.hill@york.ac.uk>"]
version = "0.1.0"
[extras]
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe"
[targets]
test = ["TestItems", "TestItemRunner"]
and test/runtests.jl
using TestItemRunner
and running from the command line:
$ julia --project=. test/runtests.jl
ERROR: LoadError: ArgumentError: Package TestItemRunner not found in current path.
- Run `import Pkg; Pkg.add("TestItemRunner")` to install the TestItemRunner package.
If I instead use the alternative, possibly unstable test/Project.toml method:
Project.toml:
name = "mvce"
uuid = "5c5c69df-07ce-4eec-9db9-de18ccd496a9"
authors = ["Peter Hill <peter.hill@york.ac.uk>"]
version = "0.1.0"
The [targets] approach is (as far as I’m aware) only compatible with using ]test in the REPL (or explicitly calling the Pkg.test API). If you want to run your tests as a standalone “script”, using a dedicated test Project is the best approach.
One other way is to use TestEnv.jl to create the test environment. That works with the targets approach, and allows rerunning tests in the same Julia session (unlike Pkg.test which starts a separate process).