Search code examples
c#unit-testingunity-game-enginevisual-studio-codenunit

VSCode + Unity's test framework?


I installed VSCode for Unity game development a few weeks ago and have been using it as an alternative to my usual setup of VS + Resharper. I enjoy VSCode quite a bit, especially given how fast and lightweight it is.

One problem I have, however, is writing tests. It's standard practice at our studio to create unit tests for certain features we implement, and we so we have an assembly for running tests in a Unity project.

There's a testing .asmdef that references the NUnit framework DLL and the assembbly that has the code I want to test. In VS, if I navigate through the code, it all looks fine. If I switch to VSCode, however, it tells me there's compilation errors all over the place, because VSCode can't see any of the NUnit classes or the classes from the assembly I want to test (in Unity, I get 0 compilation errors even when writing new code).

Is there any VSCode setup I can do to get rid of the compilation errors and write tests normally, or do I have to switch to VS to write tests?


Solution

  • UPDATE: A work colleague helped me out and linked me this extension which clears up the compilation errors.

    It looks like it lets me run tests from the IDE, too, but I haven't set it up yet as I just run them from Unity's Test Runner window. This isn't a priority for me, so I'll mark this as the answer.