Hi,
I was reading the page on unit testing and I found that the suggested method ] test
was rather slow due to pre-compilation, making it unusable for me during development.
There is a much faster way to incrementally run tests, using Revise.jl.
For example I have a file test/runtests.jl
(from BestieTemplate.jl) which collects my tests.
#=
Don't add your tests to runtests.jl. Instead, create files named
test-title-for-my-test.jl
The file will be automatically included inside a `@testset` with title "Title For My Test".
=#
function runtests()
for (root, dirs, files) in walkdir(@__DIR__)
for file in files
if isnothing(match(r"^test-.*\.jl$", file))
continue
end
title = titlecase(replace(splitext(file[6:end])[1], "-" => " "))
@testset "$title" begin
@info "Running test: $file at dir $root"
include(root * '/' * file)
end
end
end
end
# Run the tests
runtests()
From Revise.jl I call includet to track any changes to my tests:
julia> using Revise
includet("test/runtests.jl")
runtests()
Now I can run my tests, make changes, create new tests all without having to pre-compile.
Would it make sense to add this as a section to the unit testing docs?