# Activating test dependencies?

**URL:** <https://discourse.julialang.org/t/activating-test-dependencies/48121>\
**Category:** General Usage\
**Created:** [October 10, 2020, 7:07pm UTC](https://discourse.julialang.org/t/activating-test-dependencies/48121 "2020-10-10T19:07:09Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Post date:** [October 10, 2020, 7:07pm UTC](https://discourse.julialang.org/t/activating-test-dependencies/48121/1 "2020-10-10T19:07:09Z")

</div>

Is it possible to activate the extras/test dependencies of a project, e.g. for running tests manually/interactively (instead via `Pkg.test()`)?

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [October 10, 2020, 7:12pm UTC](https://discourse.julialang.org/t/activating-test-dependencies/48121/2 "2020-10-10T19:12:54Z")

</div>

cd into the directory and start julia there with `julia --project`. Then in package mode do `instantiate`. Then `include("runtest.jl")` (or whatever).

---

<div class="post-metadata">

**Author:** ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Post date:** [October 11, 2020, 3:23am UTC](https://discourse.julialang.org/t/activating-test-dependencies/48121/3 "2020-10-11T03:23:04Z")

</div>

Sure, that activates the project and it’s deps become available. But the packages in `[extras]`, resp. referred to by `test = ...` in `[targets]` aren’t part of a normal project activation. At least I’ve never had them available by just activating/instantiating a project. Have I missed something?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [October 11, 2020, 7:31am UTC](https://discourse.julialang.org/t/activating-test-dependencies/48121/4 "2020-10-11T07:31:17Z")

</div>

No easy way:  
[https://github.com/JuliaLang/Pkg.jl/issues/624](https://github.com/JuliaLang/Pkg.jl/issues/624)

I usually manually create the project file and activate it

---

<div class="post-metadata">

**Author:** ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Post date:** [October 11, 2020, 9:56am UTC](https://discourse.julialang.org/t/activating-test-dependencies/48121/5 "2020-10-11T09:56:41Z")

</div>

Ah, thanks Mosè! I was wondering if there was an issue about it, but didn’t find it.

I guess for debugging complex packages, one would also want all optional deps (loaded via Requires.jl) of the package in question available … but that’s of course beyond the job of Pkg.

---

<div class="post-metadata">

**Author:** ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Post date:** [October 11, 2020, 10:07am UTC](https://discourse.julialang.org/t/activating-test-dependencies/48121/6 "2020-10-11T10:07:37Z")

</div>

Oh silly me - the optional/Require deps should obviously be part of the test deps of the package already, so no problem there.

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [October 13, 2020, 9:24am UTC](https://discourse.julialang.org/t/activating-test-dependencies/48121/7 "2020-10-13T09:24:40Z")

</div>

Post Julia 1.1 solution:

### Setup:

1. Create a `test/Project.toml`
2. in it all your test-time dependencies.
3. Remove them and the other test time stuff from the main Project.toml

### use

For testing `] test` will work as before.

For manually activating:

1. Activate the main environment
2. Do `push!(Base.LOAD_PATH, "./test")`, (assuming currently directory is in basedir of project)
3. You should now be able to using any package from either `Project.toml`

This feels like a gross hack to me.  
There has been issues about creating nicer ways to activate stacked environments.  
Maybe @StefanKarpinski or @kristoffer.carlsson have more thought in this direction

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 13, 2020, 9:29am UTC](https://discourse.julialang.org/t/activating-test-dependencies/48121/8 "2020-10-13T09:29:04Z")

</div>

> [@oxinabox](#):
>
> Maybe @StefanKarpinski or @kristoffer.carlsson have more thought in this direction

Yes, thoughts to make it better. Will happen at some point 🙂

---

<div class="post-metadata">

**Author:** ![cscherrer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cscherrer/32/7631_2.png) [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Post date:** [February 14, 2021, 3:16pm UTC](https://discourse.julialang.org/t/activating-test-dependencies/48121/9 "2021-02-14T15:16:58Z")

</div>

Is this approach stable now? I like it much better, but it had bitten me before:  
[https://github.com/JuliaLang/Pkg.jl/issues/1788](https://github.com/JuliaLang/Pkg.jl/issues/1788)

---

<div class="post-metadata">

**Author:** ![goretkin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goretkin/32/167_2.png) [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Post date:** [April 23, 2021, 5:05pm UTC](https://discourse.julialang.org/t/activating-test-dependencies/48121/10 "2021-04-23T17:05:11Z")

</div>

For this to work, I think it is necessary for `test/Manifest.toml` to exist. To create it, do `]activate test` and `]instantiate`.

But then version resolution doesn’t seem to happen jointly. I’ve had more success with working in the `test` environment and doing `]dev .`.

---

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [February 19, 2022, 8:36pm UTC](https://discourse.julialang.org/t/activating-test-dependencies/48121/11 "2022-02-19T20:36:30Z")

</div>

A bit late to the party, but [TestEnv.jl](https://github.com/JuliaTesting/TestEnv.jl) now exists and solves exactly this problem.

---

<div class="post-metadata">

**Author:** ![oschulz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oschulz/32/2998_2.png) [@oschulz](https://discourse.julialang.org/u/oschulz)\
**Post date:** [February 21, 2022, 10:03am UTC](https://discourse.julialang.org/t/activating-test-dependencies/48121/12 "2022-02-21T10:03:09Z")

</div>

Yes, TestEnv.jl is great, thanks again to @oxinabox for creating it!
