#Unity Test Framework with Multiplayer Playmode

1 messages · Page 1 of 1 (latest)

open trail
#

In Multiplayer Playmode, I see that it has Unity.Multiplayer.Playmode.CurrentPlayer.ReportResult(bool, string, string, int), with the docs saying it is useful for runtime tests and am wondering if anyone has integrated it with the unity test framework in order to run some automated multiplayer tests. Have had a look around but have not found anything useful about it.

Currently on unity 6000.1.17f1

modern lion
#

It's unfortunate that this method made its way in the public API because currently it really has no use yet. Our intent is that Multiplayer Play Mode can eventually be used with Unity's test framework to run integration tests, but we're not all there yet unfortunately.

You can see things starting to fall into place in 6.4 where it's possible to launch a scenario programmatically:
https://docs.unity3d.com/6000.4/Documentation/ScriptReference/Unity.PlayMode.Editor.PlayModeScenarioManager.html

But that still requires that the scenario be created from the UI. Creating scenarios from code will come at a later point. And then we'll look at adding APIs to communicate with the different instances. But as I said we're not there yet and in the meantime I'd suggest viewing MPPM as a tool pretty much only for manual testing.

nova pasture
#

Can you recommend any way to use MPPM with testing? We (I work with David) are manually running a test runner locally but there doesn't seem to be any way to get it to run on the instances because they start in play mode and the test runner needs to start from editor mode. (I'm assuming if we managed to stop an instance to start the test runner it would be killed before we could do anything)

modern lion
#

I'm not sure I fully understand what you're trying to do with your test runner here, but am I correct that you are trying to execute something before an instance enters play mode? If that's the case you should have some options.

The extra instances are just stripped-down editors, so they'll still run any editor script you have set up in your project. For example a callback registered with playModeStateChanged will still execute in your instances. So you could check for the ExitingEditMode state and have some code run right before your instance enters play mode.

If you're using scenarios, you can also go to the "Play Mode Status Window" (from the drop-down where you select your scenario) and switch your instances to "Manual Control" and activate them manually. This will give you access to the instances while you are still in edit mode. The instances will also survive exiting play mode in that state. Unfortunately in terms of UI you're still pretty limited by what you can do in those extra instances (e.g. no inspector in edit mode) so this might not be that useful. It does make iteration faster though.

keen stump
#

Hey! could you provide more context about the test your trying to run? maybe an example?

open trail
#

Overall the goal is to have a test run which can launch new instances of the game in a state where they can run a specified test and report about the result so that some multiplayer functionality of the game can be evaluated as correct or not. Our multiplayer needs to be deterministic so some tests would enable us to better make sure nothing with it breaks.
We currently have something which is mostly working by doing a test build and when a test runs, launching that build and using UnityEditor.Networking.PlayerConnection; and UnityEngine.Networking.PlayerConnection; to handle the communication of the current state between the editor and the built player. The hope was that MPPM could be used to speed up iteration times by avoiding the need to have to make a test build for every change that is made, but it seems that is not possible.

modern lion
#

Yes, currently that is not possible.

paper abyss
nova pasture
#

I should also note we are currently on 6.3 and currently have no intention of moving until the next LTS, which is quite unfortunate that Unity decided to move MPPM from a package to internal as now it doesn't look like we'll be getting any updates unless some are planned to be backported? We will probably have a poke around and see if there is anything we can use internally even if it's not supported if it saves us from having to implement something now (if it breaks later we'll just implement it later)

nova pasture
paper abyss
modern lion
# nova pasture I should also note we are currently on 6.3 and currently have no intention of mo...

Backports for new features will be evaluated on a per-feature basis. Unfortunately the work we're doing to be able to interact with MPPM programmatically is not going to be backported. It relies on heavy refactoring of the code base which would be too risky to bring over to an LTS release.

I understand that this is frustrating. It's unfortunate that for 6.3 specifically it leaves users in the uncomfortable position of not having the features available, but also not having the possibility of modifying the package for their own needs. I'll bring this up with the team, see if maybe there's something we can do to improve this.

modern lion
nova pasture
modern lion
nova pasture