# Packaging: why can't Julia find Test in Travis?

**URL:** <https://discourse.julialang.org/t/packaging-why-cant-julia-find-test-in-travis/41907>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [June 23, 2020, 3:02am UTC](https://discourse.julialang.org/t/packaging-why-cant-julia-find-test-in-travis/41907 "2020-06-23T03:02:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fusion809](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fusion809/32/6080_2.png) [@fusion809](https://discourse.julialang.org/u/fusion809)\
**Post date:** [June 23, 2020, 3:02am UTC](https://discourse.julialang.org/t/packaging-why-cant-julia-find-test-in-travis/41907/1 "2020-06-23T03:02:02Z")

</div>

I’ve got these really basic [`.travis.yml`](https://github.com/fusion809/Integration.jl/blob/c2bc963846b9ba0ab79631bcb83196c23a259b75/.travis.yml) and [`test/runtests.jl`](https://github.com/fusion809/Integration.jl/blob/c2bc963846b9ba0ab79631bcb83196c23a259b75/test/runtests.jl) files and in the Travis log I’m getting the error:

```bash
$ julia --check-bounds=yes --color=yes -e "if VERSION < v\"0.7.0-DEV.5183\"; Pkg.test(\"${JL_PKG}\", coverage=true); else using Pkg; Pkg.test(coverage=true); end"
    Testing Integration
######################################################################## 100.0%
      Added registry `General` to `~/.julia/registries/General`
Status `/tmp/jl_oGVJCk/Project.toml`
  [fe4b9952] Integration v0.1.0 `~/build/fusion809/Integration`
Status `/tmp/jl_oGVJCk/Manifest.toml`
  [fe4b9952] Integration v0.1.0 `~/build/fusion809/Integration`
ERROR: LoadError: ArgumentError: Package Test not found in current path:
- Run `import Pkg; Pkg.add("Test")` to install the Test package.
Stacktrace:
 [1] require(::Module, ::Symbol) at ./loading.jl:893
 [2] include(::String) at ./client.jl:444
 [3] top-level scope at none:6
in expression starting at /home/travis/build/fusion809/Integration/test/runtests.jl:2
ERROR: Package Integration errored during testing
Stacktrace:
 [1] pkgerror(::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/Types.jl:52
 [2] test(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}; coverage::Bool, julia_args::Cmd, test_args::Cmd, test_fn::Nothing) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/Operations.jl:1561
 [3] test(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}; coverage::Bool, test_fn::Nothing, julia_args::Cmd, test_args::Cmd, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/API.jl:327
 [4] #test#61 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/API.jl:67 [inlined]
 [5] test(; name::Nothing, uuid::Nothing, version::Nothing, url::Nothing, rev::Nothing, path::Nothing, mode::Pkg.Types.PackageMode, subdir::Nothing, kwargs::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:coverage,),Tuple{Bool}}}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Pkg/src/API.jl:80
 [6] top-level scope at none:1
The command "julia --check-bounds=yes --color=yes -e "if VERSION < v\"0.7.0-DEV.5183\"; Pkg.test(\"${JL_PKG}\", coverage=true); else using Pkg; Pkg.test(coverage=true); end"" failed and exited with 1 during .

```

and I must admit I’m a little stumped. Naturally, you may say “Just add `import Pkg; Pkg.add("Test")` to the top of runtests.jl like the error tells you to.” Well, I’ve tried that and what it complains about after making that change is that it cannot find `Pkg` ([here](https://travis-ci.com/github/fusion809/Integration/builds/172595940)’s the log). Based on these errors it seems like Travis’ Julia is pretty minimalist, so minimalist it doesn’t even have its package manager, so I’m a little stumped as to what to do.

---

<div class="post-metadata">

**Author:** ![dellison](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@dellison](https://discourse.julialang.org/u/dellison)\
**Post date:** [June 23, 2020, 5:29am UTC](https://discourse.julialang.org/t/packaging-why-cant-julia-find-test-in-travis/41907/2 "2020-06-23T05:29:16Z")

</div>

I believe the issue you’re seeing is because `Project.toml` doesn’t include the dependency on `Test` (or `Pkg`). Here’s a way to fix that:

- `julia> ] add Test`

`Project.toml` will now have:

```julia
[deps]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

```

If you only need `Test` when you run your tests (i.e. you don’t have `using Test` or `import Test` anywhere in /src/), you can edit this slightly to:

```julia
[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]

```

I think I remember reading that there will be a way to do this in a single step at some point in the future, but in any case, committing that change to git should fix the tests on travis.

(I opened a [PR](https://github.com/fusion809/Integration.jl/pull/1) to make certain this would work, but you might like to make the change yourself 🙂 )

---

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [June 23, 2020, 5:48am UTC](https://discourse.julialang.org/t/packaging-why-cant-julia-find-test-in-travis/41907/3 "2020-06-23T05:48:26Z")

</div>

To add to this: the `[extras]` and `[targets]` are necessary on julia versions \< 1.2. From 1.2 onward you may add `Test` as a dependency in the `test` environment, that is

```julia
pkg> activate test
test> add Test

```

and the `test/Project.toml` file would reflect `Test` as a dependency. Following this you may import `Test` in your `runtests.jl`.
