Unity testing framework project references to main project

Hey Unity people,

I have a Unity solution that has multiple projects with the game itself being the main proj. When I create a Play mode Test assembly or Editor mode test assembly, Unity editor creates a separate csproj inside the solution structure, but when I try to reference the types from the main project to test them they are not visible from within the test project. I see no way of adding a reference to the main project from this test project they way I would do it in a typical C# app. I’m guessing I’m doing this wrong. Any hints on what needs to be fixed? Thanks very much.

The unit test folder has an Assembly Definition (.asmdef) file. Select that, in the Inspector you can add dependencies to other .asmdef.

If your own code isn’t using asmdef then you’ll have to create at least one, or two if you have editor scripts because even “Editor” folders governed by an asmdef aren’t going to be editor-only scripts without adding an editor-only .asmdef.

Thanks, CodeSmile, that’s very helpful. All the code is bundled into default Assembly-CSharp.dll and hence the problem. Breaking that code into assemblies will be quite the task due to lots of coupling between the code, but I’ll see if I can do that.