# Using TestItemRunner snippets & modules when troubleshooting

**URL:** https://discourse.julialang.org/t/using-testitemrunner-snippets-modules-when-troubleshooting/123057
**Category:** General Usage
**Tags:** testing
**Created:** [November 25, 2024, 8:27pm UTC](https://discourse.julialang.org/t/using-testitemrunner-snippets-modules-when-troubleshooting/123057 "2024-11-25T20:27:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ken\_Williams](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ken_williams/32/5289_2.png) [@Ken\_Williams](https://discourse.julialang.org/u/Ken_Williams)
#### Post date: [November 25, 2024, 8:27pm UTC](https://discourse.julialang.org/t/using-testitemrunner-snippets-modules-when-troubleshooting/123057/1 "2024-11-25T20:27:47Z")

</div>

I’ve been starting to use `TestItemRunner`’s new `@testsnippet` and `@testmodule` mechanisms to help organize testing code, and I’ve found it very helpful.

One thing that’s a setback, though, is that if a test fails and I need to do some troubleshooting, it’s not clear how to proceed.

- Setting a VS Code breakpoint generally doesn’t work - it did work for a little while after the feature was released a couple months ago, but these days all my tests either crash when I hit the debugger button[1], or they just don’t stop at the breakpoint.
- I tried `@run_package_tests filter = ti -> contains(ti.filename, "my_test")` from the REPL, but this generally crashes too[2].
- Copying & pasting the test code into my REPL, which was my previous go-to workaround, doesn’t work anymore because it now requires the setup module/snippet to function.

Does anyone have any recommendations for this?

* * *

[1] error generally looks like `The test process crashed while running this test`, and stack trace shows `@ Main ~/.vscode/extensions/julialang.language-julia-1.127.2/scripts/error_handler.jl:15 ERROR: Endpoint is not running, the current state is closed`.

[2] error generally looks like `LoadError: UndefVarError: 'Foo' not defined`, where ‘Foo’ is the name of the package being tested. Even if I put `using Foo` in the test.

---

<div class="post-metadata">

### Author: ![Ken\_Williams](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ken_williams/32/5289_2.png) [@Ken\_Williams](https://discourse.julialang.org/u/Ken_Williams)
#### Post date: [December 2, 2024, 4:23pm UTC](https://discourse.julialang.org/t/using-testitemrunner-snippets-modules-when-troubleshooting/123057/2 "2024-12-02T16:23:24Z")

</div>

Just a ping - I’m still interested in hearing how/whether other people deal with this part of their development workflow. Thanks.

---

<div class="post-metadata">

### Author: ![CarloLucibello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carlolucibello/32/3278_2.png) [@CarloLucibello](https://discourse.julialang.org/u/CarloLucibello)
#### Post date: [December 2, 2024, 7:04pm UTC](https://discourse.julialang.org/t/using-testitemrunner-snippets-modules-when-troubleshooting/123057/3 "2024-12-02T19:04:06Z")

</div>

Related to this, a few days ago I opened an issue in TestItems.jl asking for the possibility to include a `@testmodule` as a standard module.

> <https://github.com/julia-vscode/TestItems.jl/issues/26>
>
> Assuming I have a \`test\_module.jl\` file containing
> \`\`\`julia
> @testmodule TestModu…le begin
> ...
> end
> \`\`\`
> I would like to use it as a standard module outside of the vscode testing framework.
> Unfortunately though, the following happens
> \`\`\`julia
> julia\> using TestItems
> 
> julia\> include("test/test\_module.jl")
> 
> julia\> using .TestModule
> ERROR: UndefVarError: \`TestModule\` not defined in \`Main\`
> Suggestion: check for spelling errors or missing imports.
> \`\`\`

My use case is exactly the same as in the OP, and I didn’t find a good solution for it.
