# Unit tests, debugger, VsCode

**URL:** <https://discourse.julialang.org/t/unit-tests-debugger-vscode/113419>\
**Category:** New to Julia\
**Tags:** testing, vscode, debugger\
**Created:** [April 24, 2024, 4:34am UTC](https://discourse.julialang.org/t/unit-tests-debugger-vscode/113419 "2024-04-24T04:34:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![feribg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feribg/32/202948_2.png) [@feribg](https://discourse.julialang.org/u/feribg)\
**Post date:** [April 24, 2024, 4:34am UTC](https://discourse.julialang.org/t/unit-tests-debugger-vscode/113419/1 "2024-04-24T04:34:06Z")

</div>

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`

```julia
using TestItemRunner
@run_package_tests

```

file with the debugger config

```julia
  {
                "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

---

<div class="post-metadata">

**Author:** ![bcon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bcon/32/23495_2.png) [@bcon](https://discourse.julialang.org/u/bcon)\
**Post date:** [April 24, 2024, 2:07pm UTC](https://discourse.julialang.org/t/unit-tests-debugger-vscode/113419/2 "2024-04-24T14:07:09Z")

</div>

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](https://github.com/julia-vscode/julia-vscode/issues/3596) or open an issue with TestItem?

---

<div class="post-metadata">

**Author:** ![feribg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feribg/32/202948_2.png) [@feribg](https://discourse.julialang.org/u/feribg)\
**Post date:** [April 24, 2024, 2:24pm UTC](https://discourse.julialang.org/t/unit-tests-debugger-vscode/113419/3 "2024-04-24T14:24:38Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [July 6, 2024, 7:19pm UTC](https://discourse.julialang.org/t/unit-tests-debugger-vscode/113419/4 "2024-07-06T19:19:55Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Marius\_Kruger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius_kruger/32/904_2.png) [@Marius\_Kruger](https://discourse.julialang.org/u/Marius_Kruger)\
**Post date:** [July 12, 2024, 1:06am UTC](https://discourse.julialang.org/t/unit-tests-debugger-vscode/113419/6 "2024-07-12T01:06:02Z")

</div>

awesome, thanks, just in time 😃  
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)
