# 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:** 4

<div class="post-metadata">

**Author:** ![jlperla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlperla/32/34332_2.png) [@jlperla](https://discourse.julialang.org/u/jlperla)\
**Post date:** [March 31, 2022, 6:03pm UTC](https://discourse.julialang.org/t/how-to-use-vscode-and-repl-to-write-and-test-a-package/78818/4 "2022-03-31T18:03:42Z")

</div>

[https://github.com/JuliaTesting/TestEnv.jl](https://github.com/JuliaTesting/TestEnv.jl) is the only reproducible way I have found. Not sure who originally created it, but I think it was another beautiful package from @oxinabox

1. Create your normal package `Project.toml` file, no manifest checked into git
2. Create a `/test/Project.toml` file, again best not to check a manifest in and to use the `compat` as required, but less of an issue there,
3. Do a `] add TestEnv` to the global environment. Hopefully vscode even add/load testenv automatically at some point in the future.
4. Otherwise, keep your global environment clean (e.g. Revise, PkgBenchmark, BenchmarkTools, TestEnv but not much else) usually works best. I keep the package I am working on out of it, but probably other ways work

Just to be clear: at no point do you need to add your package to theglobal environment or manually make any temp project file, and you definetely don’t want to put test-only dependencies in the global environment,

Then to use this:

1. Start vscode in your packages folder so it starts activated.
2. To run the unit tests fully, you could just do the classic `] test` and it uses the `test/Project.toml`
3. To work interactively, given that your package is activated just go `using TestEnv; TestEnv.activate()` when you start up the REPL,

This creates, activates, and instantiates a temporary manifest that emulates what `] test` would do. Fully reproducible.

Then you can just use vscode as you normally would, executing the unit tests line by line, modify the package functions and then `<shift-enter>` or using Revise, etc. Seamless.

---

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