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

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.