Here is a working case: GitHub - lmiq/TestTests.jl
- You do need to
] add Tests
, yes (@davidanthoff can this be lifted? Seems redudant, isn’tTest
a dependency ofTestItemRunner
, which could reexport theTest
macros?) - In the main module of the package you only need to put
using TestItems
- In
runtests.jl
you need to useusing TestItemRunner
The Project.toml
must look like this one: TestTests.jl/Project.toml at main · lmiq/TestTests.jl · GitHub
I tested removing the test/runtests.jl
file, and the test items inside the main module continue to work.
Does this work for you? You can clone that package and check, of course.
In other works, a step by step would be:
Step by step
Packages to add:
import Pkg; Pkg.add("Test", "TestItems", "TestItemRunner")
Project.toml (see example here)
- Move
TestItemRunner
andTest
to[extras]
- On
[targets]
, havetest = ["Test", TestItemRunner"]
(and other deps if needed).
Main code of the package
Add using Testitems
in the main module, and @testitem
(s):
module MyPackage
using TestItems
f(x) = 1
@testitem "my test" begin
using MyPackage # must be self-contained!
@test MyPackage.f(1) == 1
end
end
The test/runtests.jl
file:
Must look like this:
using TestItemRunner
# other items can be here
@testitem "my other test" begin
using MyPackage
@test MyPackage.f(2) == 1
end
@run_package_tests