Error on running tests for a self-written package

I have written a package along with some unit tests, which I would like to be able to run once the package is added to Julia. But I get an error:

pkg> add gitlink-to-PackageName
pkg> test PackageName
ERROR: LoadError: ArgumentError: Package Test not found in current path:
- Run `import Pkg; Pkg.add("Test")` to install the Test package.

I do: pkg> add Test
which adds Test to the package list, but still ‘test PackageName’ fails with the same error.

I am using Julia 1.2.0. I can run tests on other packages I have installed.

Questions:

  1. What step am I missing, so the ‘Test’ package I load in ‘pkg’ is available to my package’s ‘runtests’?
  2. Why does ‘Test’ need installing separately, if it’s in the stdlib?

I am following the (possibly outdated) page: Finalizing Your Julia Package: Documentation, Testing, Coverage, and Publishing - Stochastic Lifestyle

I had to replace ‘using Base.Test’ with ‘using Test’, but apart from that,

  • PackageName/src has my code
  • PackageName/test has ‘runtests.jl’

$ julia test/runtests.jl runs and shows all tests passing.

cd("package dir")
] activate .
] add Test
] test packageName

What happens when you do using Test?

There doesn’t seem to be a problem with Test itself. I have a ‘runtests.jl’ file, and that runs fine, with all tests passing.

At the REPL:

julia> using Test

julia> @test 1 == 1
Test Passed

Ah, thankyou! That worked.

Those commands created a Manifest.toml and added to my Profile.toml. Once those were included in the git repository, the package manager could successfully run the tests.

1 Like