How to separate unit tests into another C# project?

In the normal C# application, i would create a separate UnitTest project in my solution, and add the projects i want to test via the project build dependencies. This way the product code would not require the test project to be built.

In Unity, however, the solutions are generated automatically, and any code inside the project folder is build, as i know.

Is there a way to unittest such that:

  • The production code is not dependent on test code in building (when i hit the play button, the test files are not build), ideally unity project should not know about the existence of tests at all?
  • The tests are in a separate, pure C#/Visual Studio project. and can be run through VS Test Runner, as in the normal C# app?

I found i could add a Unit Test Project in Visual Studio.

You may need to reference Unity Libraries inside the “Library\UnityAssemblies” folder.


Or did you mean somthing else?