Multi-threaded testing

I want to use multithreading to speed up my test suite, but it seems to “hide” the tests from the test set. Any idea why?

julia> using Base.Threads

julia> using Test

julia> @testset "Sequential" begin
           for i in 1:10
               @test true
           end
       end;
Test Summary: | Pass  Total  Time
Sequential    |   10     10  0.0s

julia> @testset "Parallel" begin
           @threads for i in 1:10
               @test true
           end
       end;
Test Summary: |Time
Parallel      | None  0.1s

Related thread: Run Pkg.test with several processors

Unrelated thread: Test code with multi-threading (they want to test multithreaded code, not test code in a multithreaded way)

I haven’t tried it, but maybe GitHub - RelationalAI-oss/XUnit.jl: XUnit.jl is a unit-testing framework for Julia. could be helpful

2 Likes

The test item framework has support for parallel test execution. In VS Code you can enable it by setting julia.numTestProcesses to the number of processes you want to use. From the command line there is the very experimental GitHub - julia-vscode/TestItemRunner2.jl to run test items in parallel.

1 Like