Skip to content

Commit 31d7ca0

Browse files
throwing exceptions on timeouts
1 parent aafded5 commit 31d7ca0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Packages/com.unity.multiplayer.samples.coop/Utilities/Testing/TestUtilities.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections;
23
using UnityEngine;
34
using NUnit.Framework;
@@ -12,7 +13,7 @@ public abstract class TestUtilities
1213

1314
/// <summary>
1415
/// Helper wrapper method for asserting the completion of a scene load to be used inside Playmode tests. A scene
15-
/// is either loaded successfully, or the loading process has timed out.
16+
/// is either loaded successfully, or the loading process has timed out and will throw an exception.
1617
/// </summary>
1718
/// <param name="sceneName"> Name of scene </param>
1819
/// <returns> IEnumerator to track scene load process </returns>
@@ -26,8 +27,8 @@ public static IEnumerator AssertIsSceneLoaded(string sceneName)
2627
}
2728

2829
/// <summary>
29-
/// Helper wrapper method for asserting the completion of a scene load to be used inside Playmode tests. A scene
30-
/// is either loaded successfully, or the loading process has timed out.
30+
/// Helper wrapper method for asserting the completion of a network scene load to be used inside Playmode tests.
31+
/// A scene is either loaded successfully, or the loading process has timed out and will throw an exception.
3132
/// </summary>
3233
/// <param name="sceneName"> Name of scene </param>
3334
/// <param name="networkSceneManager"> NetworkSceneManager instance </param>
@@ -68,6 +69,8 @@ public override bool keepWaiting
6869
if (Time.time - m_LoadSceneStart >= m_MaxLoadDuration)
6970
{
7071
TimedOut = true;
72+
73+
throw new Exception($"Timeout for scene load for scene name {m_SceneName}");
7174
}
7275

7376
return !isSceneLoaded && !TimedOut;
@@ -83,8 +86,8 @@ public WaitForSceneLoad(string sceneName, float maxLoadDuration = k_MaxSceneLoad
8386
}
8487

8588
/// <summary>
86-
/// Custom IEnumerator class to validate the loading of a Scene by name. If a scene load lasts longer than
87-
/// k_MaxSceneLoadDuration it is considered a timeout.
89+
/// Custom IEnumerator class to validate the loading of a Scene through Netcode for GameObjects by name.
90+
/// If a scene load lasts longer than k_MaxSceneLoadDuration it is considered a timeout.
8891
/// </summary>
8992
class WaitForNetworkSceneLoad : CustomYieldInstruction
9093
{
@@ -109,6 +112,8 @@ public override bool keepWaiting
109112
TimedOut = true;
110113

111114
m_NetworkSceneManager.OnSceneEvent -= ConfirmSceneLoad;
115+
116+
throw new Exception($"Timeout for network scene load for scene name {m_SceneName}");
112117
}
113118

114119
return !m_IsNetworkSceneLoaded && !TimedOut;

0 commit comments

Comments
 (0)