Unit tests, debugger, VsCode

What is the recommended workflow for using tests + vscode official Julia extension + debugger. It seems like they just can’t be made to work together.

If I run the file runtests.jl

using TestItemRunner
@run_package_tests

file with the debugger config

  {
                "type": "julia",
                "request": "launch",
                "name": "Run active file",
                "program": "${file}",
                "stopOnEntry": false,
                "juliaEnv": "${command:activeJuliaEnvironment}",
                "args": []
            },

the breakpoints don’t trigger.

If I run specific tests with Debug Test context menu in VSCode, nothing happens.

If I run an individual test file that includes TestItem @testitem things break with missing packages etc.

I’m assuming setting up a debugger and unit tests should be very well documented. Is the TestItemRunner package abandoned, there is no docs there, not even mentioning the fact that the imported modules need to go inside the individual @testitems or they won’t be loaded.

Maybe someone can recommend a better and more useful setup to have VSCode + local test / debugger + CI runner

I’ve used TestItems on a few previous packages but just yesterday was unable to get it to discover tests in a new package, “Package | None 0.0s”. Reverting to standard Tests, I am able to run them in test/runtests.jl and via Pkg.test(), but julia-vscode does not detect or run them.
Something seems to be broken, but it’s a little hard to trace through vscode.

Perhaps you can add on to vscode doesn't discover or run tests · Issue #3596 · julia-vscode/julia-vscode · GitHub or open an issue with TestItem?

Overall my experience with the TestItems package is it’s just broken and not well documented / supported. I hit another bug where using Pkg inside the tests doesn’t work, which is rather useful to get metadata for the package you are testing like it’s path etc. I will give the standard testing a shot and live without the VSCode runner, just curious whats the Julia ecosystem recommended approach, seems like testing is very fragmented and kinda left behind.

UPDATE: debugging the runtests.jl file with regular Test.jl tests also doesn’t work, breakpoints are skipped… I find it hard to believe that the best way is to copy paste a test into a runnable file and debug that every time, there must be a better way ? Does this merrit a bug report in TestItemRunner.jl ?

The VS Code extension preview now has proper support for debugging test items, please give it a try and report any bugs you experience with it!

1 Like

awesome, thanks, just in time :smiley:
I’ll just note for others here that for me it only started working from julia-1.11.0-rc1
(it is not working with Julia 10.4 for me)