How to debug-break in unit test

Can anyone suggest how to debug break in unit test. My unit tests use standard Test.jl with @testset, @test macro and I start them from VS Code as ‘] test MyPackage’.

Thank you very much,


It is hard to suggest a specific action without more details. @test just gets a boolean that should be true, so usually one tries to figure out why it isn’t. You should be able to investigate the broken test in isolation.

Nothing special. I have set of tests in test folder and use Test.jl, all standard. It is usually not needed to debug them, because they are small and, if fail, it is enough to review the code. But some tests are bigger, sort of end to end, I want to debug break at some function to see values of local variables, and step through.

I usually run tests from Julia REPL in VS Code: activate my project and then do ‘] test MyProject’. There is no option to start with debugger there. I wonder if it is possible to insert some macro at some function to @debug_break, or something.

Or maybe you can advice another method, such as organize test so that they can be called from REPL as regular function (so it is easy to run them with debugger)?

Tests are code like any other Julia code, so you can just run them.

So, for example, if I have the following test, how do I run it under debugger then?

@testset "mytest" begin
           # some code goes here 
           @test a == b

(note that some code may depend on something included earlier, with regular code I can just ‘using MyPackage’ and then call any function under debugger with some parameters.)

There is not much you can debug about a == b, you should debug the code that generates a and b. Eg maybe run # some code, in the debugger if you prefer.