How to add a package as a test dependency from the REPL?

To add a dependency ony for testing, I followed the instructions here: https://docs.julialang.org/en/v1/stdlib/Pkg/#Test-specific-dependencies-1.

But this involves editing Project.toml directly. Can this be done through the REPL (like pkg> add ... does for a proper dependency)?

Related (for Julia pre-0.7): Dependency only for testing

1 Like

AFAIK you still need to edit the Project.toml.

A convenient way to do this is to pkg> add TheDependency, then open the editor and just move the line and to [extras] and add it to the relevant line in [targets].

7 Likes

This is what I am doing now. Thanks. I see you already opened an issue to request this:

Hello,

How should we add a test-only package dependency from the REPL, without copy-pasting from the Project.toml?

3 Likes