What should be a really simple question here, but I can’t seem to find an answer. I can’t figure out what defines the difference (technically) between an Editor Mode test and a Play Mode test. I know what the applicable difference is, that’s the only info I can find. What I don’t know is what defines them technically.
What I mean is, I can create an asmdef file for the tests, I can annotate them with [Test], and I can test stuff. But they all show up as Play Mode tests. How do you make a test an Editor Mode test? I’ve got a lot of tests that just test basic logic, and those should probably be Editor Mode tests. I’ve always just been running them as Play Mode tests. But I’d like to correct that.
I always use two different assemblies for play and editor mode tests. The editor mode .asmdef file only includes the editor platform. Therefore all test in there are editor tests by default. Alternative you can control the test type by additional attributes.
You switch test mode in TestRunner with the (now) three toggle buttons: Edit Mode, Play Mode, and Player.
The only guarantee you can make is to mark your editor-only test assembly definition exactly that: an editor-only assembly. Unselect the “all platforms” checkbox, then unselect all platforms (use “deselect all” at the bottom), then check only the Editor platform checkbox. These tests will only be listed in Edit Mode tests.
But unless you use UnityEditor namespace types, you can just leave it as is and simply switch to Edit Mode tests. These run a bit faster because there’s no “enter playmode” occuring.
Oh, I see. It’s the included platforms list, which is empty by default, which makes it default to Any Platform. And you have to set it to just include Editor. Easier to configure this in the editor, as there it gives you a list with checkboxes. Honestly, I had seen that list before, but I didn’t notice the Editor entry and didn’t think that was controlling it.