# How to use VSCode and REPL to write and test a package?

**URL:** https://discourse.julialang.org/t/how-to-use-vscode-and-repl-to-write-and-test-a-package/78818
**Category:** VS Code
**Tags:** question, package
**Created:** [March 31, 2022, 3:28pm UTC](https://discourse.julialang.org/t/how-to-use-vscode-and-repl-to-write-and-test-a-package/78818 "2022-03-31T15:28:31Z")
**Posts on this page:** 1
**Showing post:** 54

<div class="post-metadata">

### Author: ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)
#### Post date: [August 25, 2022, 7:09pm UTC](https://discourse.julialang.org/t/how-to-use-vscode-and-repl-to-write-and-test-a-package/78818/54 "2022-08-25T19:09:48Z")

</div>

Thanks!

1. I still find that I need Method 2 to run line-by-line.
2. What you say is true except in the important case that the line of code you are trying to run from your package `src` requires a package dependency. For example, `using MyPackage; df = DataFrame()` will not work even if `DataFrames.jl` is a dependency of `MyPackage.jl`. I could `using MyPackage, DataFrames; df = DataFrame()`, but then I have to install `DataFrames` in my test environment and it could use a different version than is allowed in `MyPackage`’s `Project.toml`.
3. I have Revise working like it should now. I meant that clicking “Run and Debug” on my test file runs very slow compared to “Ctrl+Enter”-ing a few choice lines in `src` using Method 2.

One option I found recently is the `@run` macro defined in VSCode. Writing `@run f(x)` in the REPL will start debugging on just that MyPackage function (as opposed to running your entire test file). It is still somewhat slow and doesn’t work on individual lines, but it works pretty well as long as your functions are broken down into small/cheap enough pieces. A limitation of this approach though is that you cannot define new variables once you are in the debugger like you could if you were in the REPL.

> [@Any way to save variables to WorkSpace from the Debug Console in VSCode?](https://discourse.julialang.org/t/any-way-to-save-variables-to-workspace-from-the-debug-console-in-vscode/84933):
>
> I seem to be able to edit existing workspace variable values from the debug console, but I am not able to define new variables. [image] [image] I want to be able to test and play with the next line after my breakpoint before actually stepping the debugger and erroring out my whole session, but this limitation makes it difficult. [image] Is there any way to get a full REPL session with the environment as it would be inside some nested function?

---

_[View the full topic](https://discourse.julialang.org/t/how-to-use-vscode-and-repl-to-write-and-test-a-package/78818)._
