Enable Playmode Tests for All Assemblies option missing

I’m fairly new to unit testing but am trying to write a new playmode test. I’m working in a large codebase that hasn’t been using assembly definitions up to this point, and we don’t want to introduce assembly definitions at this time.

I understand that you should be able to run playmode tests on all assemblies (I assume even Assembly-CSharp) if you “enable playmode tests for all assemblies”. In the manual on playmode tests it mentions enabling tests for all assemblies by opening the context menu in Test Runner (see below)

https://docs.unity3d.com/Packages/com.unity.test-framework@1.0/manual/workflow-create-playmode-test.html

However, I can’t find the same command in my Test Runner’s context menu (see below). Is this a glitch/bug with unity? I haven’t been able to find much online.

Thanks!

3 Likes

Did you solve this? I’m experiencing the same.

No, I ended up using assembly definitions and was never able to get the option to show up

Did anyone solve this issue yet?

In later versions (as specified in the docs), you have to open the projectsettings.asset file and set “playModeTestRunnerEnabled:” to 1

4 Likes

That seems to be explained on Workflow: How to create a Play Mode test | Test Framework | 1.1.33 indeed, but in 2021 the behaviour is different:

  • Setting the flag manually in ProjectSettings.asset will only result in a popup saying “Disable playmode tests for all assemblies - You must restart the editor now.”
  • If you don’t close the editor and still try to access your game classes, it won’t work. Right-clicking on the Test Runner tab won’t show “Disable playmode tests for all assemblies” either. So Unity actually already force-disabled it.
  • After closing the editor, the flag will be auto-reverted to 0.

Therefore, I couldn’t enable playmode tests for all assemblies, and the only way to test game classes via direct access now seems to create custom assemblies for your game scripts (as recommended on the same page).

3 Likes

Can you show how you do it?

Is there any update on that? I don’t want to create assemblies for my files, since 3rd parties plugins doesn’t always support them.

I noticed same behavior as @huulong but in 2020.3.20f1 version.

Creating assemblies in our game has been an immensely difficult process. Our git submodules need to reference packages installed through the Asset Store, so every assembly in every submodule needs to reference things outside the submodule, which completely breaks the point of assembly definitions. While in theory we could move packages into the submodules themselves, that’s not possible with all the packages we have installed. Also, it’s an absolutely ridiculous thing to consider.

All we want is to be able to create Playmode tests that can reference things in the game. That’s it. Why is Unity Technologies actively fighting this?

7 Likes

We just wasted some time on this too.
Could someone from Unity please change this help text to reflect the intended behaviour? It’s very misleading!
We’re new to the Test Runner but it does seem a bit weird to make it so difficult to set up - I’m sure there are good reasons not to enable it for all assemblies but it’s definitely the most beginner friendly way for it to work.
In the meantime we’re just not going to use this package - but we’d really like to! Hope this gets resolved.
8027633--1034483--upload_2022-4-7_11-52-1.png

2 Likes

Wasted an entire day of getting this to work.
To clarify, there’s absolutely no way of accessing game code without using asmdefs?

Sidenote, I’ve tried creating an asmdef file for the entire project (that would just mimic Assembly-CSharp) but 999+ compile errors started showing up.
Tried to manually link up some stuff, but that process is extremely tedious, since you have to manually click on the + every time to add a single reference. Also, searching in project view with t:asmdef works, but there’s no way you can just drop them all together on the asmdef references list (like you can with other inspectors).

I’ve been using TestRunner for years (since 2017?) but in 2020/2021 I find it completly impossible to get fscking UnityEditor to run a single PlayMode test - Unity broke it, and put this shoddy excuse for bad code in place instead.

Has anyone logged bugs on this? It seems it’s been badly broken for the last couple of years (I’m suffering this now because moving from 2019 LTS to 2020/2021 LTS)

1 Like

so im attempting to use pubnub, installed it and if “Enable Playmode Tests for All Assemblies” is missing, then I cannot use it at all?

Update: I finally got it to work by manually editing the Unity configuration files OUTSIDE the UnityEditor - there’s showstopper bugs in the Editor UI code that apparently no-one has been testing/fixing for a while. I went through and deleted options that looked suspicious, and (by reading config files from old versions of Unity - 2018 etc) second-guessed the stuff the Editor was tryig and failing to do.

I submitted at least one easily reproducible bug, it’s been 3 months and no response from Unity.

I recommend finding someone else who’s got unit tests working in the exact way you want, and asking them to send you a ZIP file of their Unity Project, then you can read the text files by hand and make changes until you can get it working in your project.

2 Likes

Same Problem here, simply want to test my Scripts in PlayMode.
This is very frustrating, when there is something like TestRunner and you work yourself in how it works…to end up that you cant test your Scripts.

1 Like

same problem trying to use pubnub. anyone find a fix yet?!

This was frustrating. Needed to add [RequiresPlayMode] attribute:

//For all tests in the class

[TestFixture]
[RequiresPlayMode]
public class TestClass

//Or individual tests

[UnityTest]
[RequiresPlayMode]
public IEnumerator Some_Test()

Hello! We have quite big project with old spaghetti code and we want to setup play mode tests, but creating assemblies really painful process for us. Is there any other options?

You should probably roll your own testing framework. You lose the UI, which is a bit of a downer, but the Untiy built testing framework is both clunky and restrictive while having too few features.