Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
### [1.3.9] - 2023-08-21
- Removed player metada fields that were using obsolete APIs (DSTR-880).
- Added note to documentation on mitigation of problem reported in (DSTR-600).
- Fixed an issue where the test runner ui causes progress bars to flicker or not show at all (DSTR-828).
  • Loading branch information
Unity Technologies committed Aug 21, 2023
1 parent a72dcc9 commit 96062a8
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Changelog
### [1.3.9] - 2023-08-21
- Removed player metada fields that were using obsolete APIs (DSTR-880).
- Added note to documentation on mitigation of problem reported in (DSTR-600).
- Fixed an issue where the test runner ui causes progress bars to flicker or not show at all (DSTR-828).

### [1.3.8] - 2023-07-05
- Send new UTP messages regarding player and system settings (DSTR-831)

Expand Down
34 changes: 34 additions & 0 deletions Documentation~/reference-async-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,37 @@ public class AsyncExample
The following shows the result of running this example in the **Test Runner** window:

![Run async test example](./images/async.png)

## Editor freezing on `Assert.ThrowsAsync` and workaround

NUnit's assertion for asynchronous code, [Assert.ThrowsAsync](https://docs.nunit.org/articles/nunit/writing-tests/assertions/classic-assertions/Assert.ThrowsAsync.html), blocks the calling thread until the async function you pass in completes. By default Unity runs asynchronous functions on the main thread in case they need to call the Editor API, which means `Assert.ThrowsAsync` can lock up the main thread and cause the Editor to freeze.

To workaround this problem, you can unwrap the `Assert.ThrowsAsync` logic into your own `try`/`catch` blocks and assert that you caught something. For example, **do** this:

```
[Test]
public async Task ThisDoesNotLockTheMainThread()
{
bool caught = false;
try
{
await Task.Delay(1000); throw new System.Exception("Hello world."); }
catch (System.Exception x)
{
caught = true;
}
Assert.That(caught);
}
```

**Instead of** this:

```
[Test]
public void ThisLocksTheMainThread()
{
Assert.ThrowsAsync<System.Exception>(async () =>
{ await Task.Delay(1000); throw new System.Exception("Hello world."); }
);
}
```
2 changes: 2 additions & 0 deletions UnityEditor.TestRunner/Api/Analytics/AnalyticsReporter.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !UNITY_2023_2_OR_NEWER
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -158,3 +159,4 @@ private static IEnumerable<NUnitAttribute> GetAttributes(ITest node)
}
}
}
#endif
2 changes: 0 additions & 2 deletions UnityEditor.TestRunner/CommandLineTest/SettingsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public Api.ExecutionSettings BuildApiExecutionSettings(string[] commandLineArgs)
string[] testFilters = null;
string[] testCategories = null;
string testSettingsFilePath = null;
int testRepetitions = 1;
int? playerHeartbeatTimeout = null;
bool runSynchronously = false;
string[] testAssemblyNames = null;
Expand All @@ -47,7 +46,6 @@ public Api.ExecutionSettings BuildApiExecutionSettings(string[] commandLineArgs)
new CommandLineOption("editorTestsCategories", catagories => { testCategories = catagories; }),
new CommandLineOption("testCategory", catagories => { testCategories = catagories; }),
new CommandLineOption("testSettingsFile", settingsFilePath => { testSettingsFilePath = settingsFilePath; }),
new CommandLineOption("testRepetitions", reps => { testRepetitions = int.Parse(reps); }),
new CommandLineOption("playerHeartbeatTimeout", timeout => { playerHeartbeatTimeout = int.Parse(timeout); }),
new CommandLineOption("runSynchronously", () => { runSynchronously = true; }),
new CommandLineOption("assemblyNames", assemblyNames => { testAssemblyNames = assemblyNames; }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ public void Setup()
{
#if UNITY_2021_2_OR_NEWER
m_oldApplicationIdentifier = PlayerSettings.GetApplicationIdentifier(NamedBuildTarget.Android);
PlayerSettings.SetApplicationIdentifier(NamedBuildTarget.Android, "com.UnityTestRunner.UnityTestRunner");
#else
m_oldApplicationIdentifier = PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android);
#endif
PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, "com.UnityTestRunner.UnityTestRunner");
#endif


if (RequiresLegacyConnectionMechanism)
PerformLegacySetup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private IDictionary<BuildTarget, IPlatformSetup> GetSetup()
#endif
{BuildTarget.Android, m_AndroidPlatformSetup},
{BuildTarget.WSAPlayer, m_UwpPlatformSetup},
#if !UNITY_2023_1_OR_NEWER
#if !UNITY_2022_2_OR_NEWER
{BuildTarget.Lumin, m_LuminPlatformSetup},
#endif
#if UNITY_2019_3_OR_NEWER && !UNITY_2023_1_OR_NEWER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void Setup()
// Otherwise we can use the existing configuration specified by the user in Build Settings.
if (Environment.GetEnvironmentVariable("UNITY_THISISABUILDMACHINE") == "1" || wsaSettingNotInitialized)
{
#if UNITY_2023_1_OR_NEWER
#if UNITY_2021_3_OR_NEWER
#else
EditorUserBuildSettings.wsaSubtarget = WSASubtarget.PC;
#endif
Expand Down
2 changes: 1 addition & 1 deletion UnityEditor.TestRunner/TestLaunchers/PlayerLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private static bool BuildAndRunPlayer(PlayerLauncherBuildOptions buildOptions)
}
#endif
// For now, so does Lumin
#if !UNITY_2023_1_OR_NEWER
#if !UNITY_2022_2_OR_NEWER
if (buildOptions.BuildPlayerOptions.target == BuildTarget.Lumin)
{
buildOptions.BuildPlayerOptions.options &= ~BuildOptions.ConnectToHost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public IEnumerator<ITestAdaptor> GetTestListAsync(TestPlatform platform)
}

m_TestListCache.CacheTest(platform, test.Current);
#if !UNITY_2023_2_OR_NEWER
AnalyticsReporter.AnalyzeTestTreeAndReport(test.Current);
#endif
yield return m_TestAdaptorFactory.Create(test.Current);
}
}
Expand Down
8 changes: 7 additions & 1 deletion UnityEditor.TestRunner/TestRunnerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,14 @@ private static void UpdateProgressStatus(TestRunProgress progress)

private static void UpdateProgressBar()
{
if (runProgress == null || runProgress.HasFinished)
if (runProgress == null)
{
return;
}

if (runProgress.HasFinished)
{
runProgress = null;
EditorUtility.ClearProgressBar();
return;
}
Expand Down
12 changes: 4 additions & 8 deletions UnityEditor.TestRunner/UnityTestProtocol/Data/PlayerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
internal class PlayerSettings
{
public string ScriptingBackend;
public bool VrSupported;
public bool MtRendering;
public bool GraphicsJobs;
public bool GpuSkinning;
public string GraphicsApi;
public string Batchmode;
public string StereoRenderingPath;
public string StereoRenderingPath;
public string RenderThreadingMode;
public string AndroidMinimumSdkVersion;
public string AndroidMinimumSdkVersion;
public string AndroidTargetSdkVersion;
public string ScriptingRuntimeVersion;
public string AndroidTargetArchitecture;
Expand All @@ -33,9 +32,8 @@ public PlayerSettings(
string androidTargetSdkVersion,
string androidMinimumSdkVersion = "",
bool graphicsJobs = false,
bool mtRendering = false,
bool vrSupported = false,
string scriptingRuntimeVersion = "")
bool mtRendering = false
)
{
ScriptingBackend = scriptingBackend;
GpuSkinning = gpuSkinning;
Expand All @@ -47,8 +45,6 @@ public PlayerSettings(
AndroidMinimumSdkVersion = androidMinimumSdkVersion;
GraphicsJobs = graphicsJobs;
MtRendering = mtRendering;
VrSupported = vrSupported;
ScriptingRuntimeVersion = scriptingRuntimeVersion;
}

public PlayerSettings() { }
Expand Down
6 changes: 2 additions & 4 deletions UnityEditor.TestRunner/UnityTestProtocol/UtpMessageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ internal static PlayerSettingsMessage BuildPlayerSettings()
UnityEditor.PlayerSettings.Android.targetSdkVersion.ToString(),
UnityEditor.PlayerSettings.Android.minSdkVersion.ToString(),
UnityEditor.PlayerSettings.graphicsJobs,
UnityEditor.PlayerSettings.MTRendering,
UnityEditor.PlayerSettings.virtualRealitySupported,
UnityEditor.PlayerSettings.scriptingRuntimeVersion.ToString()
UnityEditor.PlayerSettings.MTRendering
),
};

Expand All @@ -112,4 +110,4 @@ internal static BuildSettingsMessage BuildBuildSettings()
return buildSettingsMessage;
}
}
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.unity.test-framework",
"displayName": "Test Framework",
"version": "1.3.8",
"version": "1.3.9",
"unity": "2019.4",
"unityRelease": "0a10",
"description": "Test framework for running Edit mode and Play mode tests in Unity.",
Expand All @@ -13,7 +13,7 @@
"repository": {
"url": "https://github.com/Unity-Technologies/com.unity.test-framework.git",
"type": "git",
"revision": "3c71367fe3a376f1a5a60b775ad2d3fb862af3ac"
"revision": "5c8a1448cee4d7607be0d60dceb66703b0cfe016"
},
"dependencies": {
"com.unity.ext.nunit": "2.0.3",
Expand Down Expand Up @@ -221,13 +221,13 @@
}
],
"relatedPackages": {
"com.unity.test-framework.tests": "1.3.8"
"com.unity.test-framework.tests": "1.3.9"
},
"_upm": {
"changelog": "- By using the editor command line new argument `-randomOrderSeed x` you can run the tests in a randomized order, where x is an integer different from 0. If a new test is added in the project the random order passing the same seed will be kept, and the new test will be placed in the random list accordigly.\n- Fix for WebGL platform target to close the browser tab when the run is completed. \n- Added TestFileReferences.json to be generated on build step of the player, so can be consumed later by Test runners to enrich data for run part."
},
"upmCi": {
"footprint": "ed15cb758498607c38e671aeced3b36da781b3d0"
"footprint": "afab85ea939bfda57db27d19b4c56f006adbe470"
},
"documentationUrl": "https://docs.unity3d.com/Packages/[email protected]/manual/index.html"
}

0 comments on commit 96062a8

Please sign in to comment.