Ocaml, vscode, unit tests to fake repl

You can write put tests right in your source code using inline tests. That link is to the dune docs on how to set it up.

It’s not too easy to run a single test with inline_tests and dune (see here and here), but inline_test style unit tests generally run fast enough.

Not sure about a little green jetbrains style triangle in vscode, but in emacs I have a shortcut that runs the tests in the current directory, which is close enough for me. You could probably set something up like that in vscode as well.

1 Like