Running tests in package?

I have a package, say Neet. (I made it with ] generate Neet.) It is a simple package, and src/Neet.jl contains only:

module Neet
export is_great
is_great() = true

I navigate to the ./Neet folder and create another directory: test.
I create a file in there named runtests.jl, and inside of it:

using Neet
using Test

@test is_great()

How do I run the test from the REPL? Base.runtests()?
I did try this, but it appears that it runs all of the Julia tests … I just want the tests in my package. Maybe I needed to export something, I’m still sort of shaky on packages.

You can use the Pkg.test method or directly use ] test.


If you are using VSCode as your IDE you can use the TestItem runner to write and execute tests. It’s very convenient and fast to run tests this way because it caches the test environment. The tests are listed in a menu in VSCode which allows you to easily choose which tests you want to run.

I used to run tests using ] test but because this reloads the test environment each time it is much slower.

1 Like