Skip to content

Commit d12da07

Browse files
van800Merge Robot
authored and
Merge Robot
committed
fix RIDER-75293 Do not allow running Unit Tests if Unity Editor is in the Play mode
1 parent bb3124f commit d12da07

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

resharper/resharper-unity/src/Unity.Rider/Integration/Core/Feature/UnitTesting/RunViaUnityEditorStrategy.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public class RunViaUnityEditorStrategy : IExternalRunnerUnitTestRunStrategy
5959
private readonly ILogger myLogger;
6060
private readonly Lifetime myLifetime;
6161
private readonly PackageValidator myPackageValidator;
62-
private readonly JetBrains.Application.ActivityTrackingNew.UsageStatistics myUsageStatistics;
6362

6463
private readonly object myCurrentLaunchesTaskAccess = new();
6564
private Task myCurrentLaunchesTask = Task.CompletedTask;
@@ -75,8 +74,7 @@ public RunViaUnityEditorStrategy(ISolution solution,
7574
FrontendBackendHost frontendBackendHost,
7675
ILogger logger,
7776
Lifetime lifetime,
78-
PackageValidator packageValidator,
79-
JetBrains.Application.ActivityTrackingNew.UsageStatistics usageStatistics)
77+
PackageValidator packageValidator)
8078
{
8179
mySolution = solution;
8280
myUnitTestResultManager = unitTestResultManager;
@@ -88,7 +86,6 @@ public RunViaUnityEditorStrategy(ISolution solution,
8886
myLogger = logger;
8987
myLifetime = lifetime;
9088
myPackageValidator = packageValidator;
91-
myUsageStatistics = usageStatistics;
9289

9390
myUnityProcessId = new Property<int?>(lifetime, "RunViaUnityEditorStrategy.UnityProcessId");
9491

@@ -310,7 +307,7 @@ private void StartTests(BackendUnityModel model, IUnitTestRun run, TaskCompletio
310307
defaultMessage = $"{defaultMessage} {playMessage}";
311308
}
312309

313-
tcs.TrySetException(new Exception(defaultMessage));
310+
tcs.TrySetException(new Exception(defaultMessage, res.Error));
314311
}
315312
});
316313
}

unity/EditorPlugin/AfterUnity56/UnitTesting/Initialization.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using JetBrains.Collections.Viewable;
23
using JetBrains.Diagnostics;
34
using JetBrains.Rd.Tasks;
@@ -31,6 +32,8 @@ public static void OnModelInitializationHandler(UnityModelAndLifetime modelAndLi
3132
model.RunUnitTestLaunch.Set(rdVoid =>
3233
{
3334
if (!model.UnitTestLaunch.HasValue()) return false;
35+
if (EditorApplication.isPlaying)
36+
throw new InvalidOperationException("Running tests during the Play mode is not possible.");
3437
var testLauncher = new UnityEditorTestLauncher(model.UnitTestLaunch.Value, connectionLifetime);
3538
return testLauncher.TryLaunchUnitTests();
3639
});

0 commit comments

Comments
 (0)