Julia 1.7.3
VS Code 1.74.3
Julia extension 1.38.2
I’m having a problem where, when I run tests with the debugger on the program I’m working on, the debugger doesn’t stop at any breakpoints I set. If I run the program normally (meaning executing a main
function) with the debugger, the debugger works as expected and stops. I tried isolating the problem with a small example problem I can share here, however I can’t get the problem to reproduce in the example. Until I do, I suppose my question is which things in particular might be causing this issue and what I should look into.
Example
In the following the example and how I use it. I think it captures the structure and use of the full program well, but evidently I’m missing something.
project_dir
|> deps
|> build.jl (empty)
|> src
|> ModuleToTest.jl
|> PackageToTest.jl
|> test
|> runtests.jl
|> Manifest.toml
|> Project.toml
ModuleToTest.jl
module ModuleToTest
export do_something
function internal_only(x)
return x + 1
end
function do_something(x)
result = internal_only(x)
return result
end
end
PackageToTest.jl
module PackageToTest
include("ModuleToTest.jl")
using .ModuleToTest
function main()
print("The magic number is $(ModuleToTest.do_something(41))")
end
main()
end
runtests.jl
using Test
using PackageToTest.ModuleToTest
@testset "tests_are_working" begin
@test true
end
@testset "test_do_something" begin
@test ModuleToTest.do_something(41) == 42
end
@testset "test_internal_only" begin
@test ModuleToTest.internal_only(41) == 42
end
Project.toml
name = "PackageToTest"
uuid = "2e0f99b1-0d8f-4296-8d0c-1c50a50d04c8"
authors = ["author"]
version = "0.1.0"
[deps]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Running the example
For debugging the program and testing it I have two debugger settings in launch.json
:
{
"type": "julia",
"request": "launch",
"name": "Run file",
"program": "project_dir/src/PackageToTest.jl",
"stopOnEntry": false,
"cwd": "project_dir/",
"juliaEnv": "${command:activeJuliaEnvironment}",
"args": []
},
{
"type": "julia",
"request": "launch",
"name": "Run tests",
"program": "project_dir/test/runtests.jl",
"stopOnEntry": false,
"cwd": "project_dir/",
"juliaEnv": ".",
"args": []
}
The launch config Run file
runs the program with its main
function, and will stop at breakpoints. Launching with Run tests
will stop at breakpoints in this example, but not in the full project. I don’t use the REPL other than to add dependencies to Project.toml
. Running tests from the PKG REPL, by activate .
then test PackageToTest
, runs the tests and works as normal, but I haven’t figured out how to use the debugger in the REPL for tests.