Whenever I move a script to a different folder, other scripts can't find it

I have a basic scene with nothing in it. In the Project hierarchy, I only have 2 folders: Scripts and Scenes. Inside Scripts, I have Timer.cs, UIHandler.cs, and a Tests directory. Inside the Tests directory, I have Tests.asmdef and TimerTest.cs.

Here is the tree-view of the Assets folder:

Assets
│   Scenes.meta
│   Scripts.meta
│
├───Scenes
│       SampleScene.unity
│       SampleScene.unity.meta
│
└───Scripts
    │   Tests.meta
    │   Timer.cs
    │   Timer.cs.meta
    │   UIHandler.cs
    │   UIHandler.cs.meta
    │
    └───Tests
            Tests.asmdef
            Tests.asmdef.meta
            TimerTest.cs
            TimerTest.cs.meta

Tests.asmdef and TimerTest.cs are for the unit testing I have made for the Timer.cs file, which is a custom Timer script, which does not inherit from MonoBehaviour.
UIHandler.cs is for handling changing the UI whenever the Timer reaches the MaxTime.

Unfortunately, this is where the errors come into play. In the current state, TimerTest.cs can’t find my Timer.cs script. Visual Studio 2022 says “The type or namespace name ‘Timer’ could not be found (are you missing a using directive or an assembly reference?)”. Unity says the same thing.

So, I thought to move the Timer.cs script up into the Tests/ directory. That fixed the errors for that script, but then UIHandler.cs starts throwing the same error. Then, I tried moving Timer.cs down into the base Assets directory, which caused UIHandler.cs to work again, but TimerTest.cs threw errors again. So it seems like the script only has errors because of the unit testing folder???

I tried giving the Timer a namespace, so that hopefully that just so happens to allow it to find my script. Nope. Instead, it can’t find the namespace as well.

I am confused. What can I do to fix this error from occurring? Do I have to get rid of the unit testing? Can I somehow get the unit tests to find the script, as well as other scripts being able to use the Timer? Or is the only solution just giving up and scrapping this entire thing?

Note the diagram in the assembly definition doc page: Unity - Manual: Assembly definitions
The primary Assembly-CSharp assembly references all other assemblies, including your own, but as it’s a one-way relationship your assemblies can’t reference anything in the main assembly.

So generally if you’re using assembly definitions, all your code needs to be organised into assemblies. So the solution is to just make an assembly for your main scripts, and have your test assembly reference the main assembly.

Well, that did it. I didn’t realize it was as simple as “make a folder called ‘Timer’, put Timer.cs into there, add an assembly definition asset into there named ‘Timer’, and make TimerTest.asmdef reference that”.

Now I’m wondering, did the manual for Unit Testing mention needing to do that and I overlooked it, or did they fail to mention that errors may occur when doing that? Because the manual makes it all seem like it’s just plug-and-play and everything will just work out, when in reality it doesn’t and needs things like that. Maybe they assumed that the dev won’t make their own class and unit test that? Idk, just seems a little overlooked.

Probably assumed if someone was at the stage of doing Unit tests they would understand how to use assembly definition assets.

They probably didn’t expect someone like me who’s smart enough to do more advanced stuff, but with patchy knowledge. Because that’s just the thing, I got interested in unit testing because of two YouTubers that I watched talking about its importance, but I guess I didn’t realize just how more advanced unit testing is compared to everything else I’ve had to do regarding Unity.

But my patchy knowledge may be the reason why I haven’t had problems with Unity. I’ve done stuff with SceneManager.LoadSceneAsync, shaders, and other more technical/difficult things, but I haven’t had problems. Then, when it comes to assembly definition assets, I get confused because I’ve never had to use them before and haven’t seen any similar issues on Google.

I mean did you read the docs before making this post?

For assembly definition assets specifically, no. For unit testing using NUnit, yes. Specifically, what happened was I searched up “Unity Unit Testing” on Google and got a link to https://docs.unity3d.com/Packages/com.unity.test-framework@1.3/manual/index.html, so I followed that. I just used the default Test script that clicking the button supplied, and everything seemed to work fine, until I created a different script, which caused the problems at the top of the thread.

When I searched for similar issues where that error kept happening, everything just said “well it turns out I accidentally deleted the .cs.meta file, adding it fixed it nvm” or similar, which was definitely not my problem