In order to test a package, I would like to use a test environment which would include many other packages, on which the tested package does not depend. I think it should be possible to have an ad hoc environment in the test folder (is that a thing?), but so far I have not been able to make it work.
Yes, that is the w
ay it is supposed to work… for example in the test environment I have CSV to load some small dataset, but then the tested package doem*t depwnds on it…
Thanks for the confirmation. I think I am now on the right track: I made a project in the test folder, and added the packages that I require to that environment. It looks like it might work.
Make an environment in the folder TestedPackage/test.
Add all the packages that are necessary to run the test to that environment.
In the folder TestedPackage one can now run ]test.
BTW when developing a package pkgname I got used to start Julia with julia --project=@pkgname which creates an environment in the .julia/environments folder (I think since 1.7). This avoids accidental addition of dependecies to the package (which itself needs to be dev-d to that environment).
And you can do ]test pkgname.
All: that is a solution, but beware, there’s a catch. The Manifest.toml in the test folder
could interfere with the manifest of the package. I now remove the Manifest.toml in the test folder
before the tests run. The issue was reported a while ago: "cannot merge projects" error · Issue #1585 · JuliaLang/Pkg.jl · GitHub
@PetrKryslUCSD , not to add to give information overload, but I wrote up a tutorial for this for the Julia docs for the upcoming 1.9 release: Unit Testing · The Julia Language I wrote it for my student assistants who were having trouble writing tests – let me know if it could use some improvements!