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

**URL:** https://discourse.julialang.org/t/how-to-add-a-package-as-a-test-dependency-from-the-repl/14313
**Category:** General Usage
**Tags:** question, package
**Created:** [August 30, 2018, 12:41pm UTC](https://discourse.julialang.org/t/how-to-add-a-package-as-a-test-dependency-from-the-repl/14313 "2018-08-30T12:41:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)
#### Post date: [August 30, 2018, 12:41pm UTC](https://discourse.julialang.org/t/how-to-add-a-package-as-a-test-dependency-from-the-repl/14313/1 "2018-08-30T12:41:27Z")

</div>

To add a dependency ony for testing, I followed the instructions here: [Pkg · The Julia Language](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](https://discourse.julialang.org/t/dependency-only-for-testing/863)

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [August 30, 2018, 1:03pm UTC](https://discourse.julialang.org/t/how-to-add-a-package-as-a-test-dependency-from-the-repl/14313/2 "2018-08-30T13:03:18Z")

</div>

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]`.

---

<div class="post-metadata">

### Author: ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)
#### Post date: [August 30, 2018, 1:15pm UTC](https://discourse.julialang.org/t/how-to-add-a-package-as-a-test-dependency-from-the-repl/14313/3 "2018-08-30T13:15:46Z")

</div>

> [@Tamas\_Papp](#):
>
> 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]` .

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

> <https://github.com/JuliaLang/Pkg.jl/issues/480>
>
> It would be great to have the functionality of #340 exposed in the interactive i…nterface, so that one does not have to manually edit the \`Project.toml\`. Eg something like
> \`\`\`julia
> pkg\> add targets.test SomePackage
> pkg\> rm targets.test SomePackage
> \`\`\`
> or simply \`add test\`.

---

<div class="post-metadata">

### Author: ![mleprovost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mleprovost/32/7166_2.png) [@mleprovost](https://discourse.julialang.org/u/mleprovost)
#### Post date: [January 18, 2021, 8:04pm UTC](https://discourse.julialang.org/t/how-to-add-a-package-as-a-test-dependency-from-the-repl/14313/4 "2021-01-18T20:04:48Z")

</div>

Hello,

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