This commit is contained in:
2026-08-28 15:56:12 +01:00
commit 4d5f73e29c
7349 changed files with 664196 additions and 0 deletions
@@ -0,0 +1,281 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
using UnityEngine.TestTools.Logging;
using UnityEngine.TestTools.TestRunner;
namespace UnityEngine.TestTools
{
internal abstract class BeforeAfterTestCommandBase<T> : DelegatingTestCommand, IEnumerableTestMethodCommand where T : class
{
private string m_BeforeErrorPrefix;
private string m_AfterErrorPrefix;
protected BeforeAfterTestCommandBase(TestCommand innerCommand, string beforeErrorPrefix, string afterErrorPrefix)
: base(innerCommand)
{
m_BeforeErrorPrefix = beforeErrorPrefix;
m_AfterErrorPrefix = afterErrorPrefix;
}
protected T[] BeforeActions = new T[0];
protected T[] AfterActions = new T[0];
protected static MethodInfo[] GetActions(IDictionary<Type, List<MethodInfo>> cacheStorage, Type fixtureType, Type attributeType, Type[] returnTypes)
{
if (cacheStorage.TryGetValue(fixtureType, out var result))
{
return result.ToArray();
}
cacheStorage[fixtureType] = GetMethodsWithAttributeFromFixture(fixtureType, attributeType, returnTypes);
return cacheStorage[fixtureType].ToArray();
}
protected static T[] GetTestActions(IDictionary<MethodInfo, List<T>> cacheStorage, MethodInfo methodInfo)
{
if (cacheStorage.TryGetValue(methodInfo, out var result))
{
return result.ToArray();
}
var attributesForMethodInfo = new List<T>();
var attributes = methodInfo.GetCustomAttributes(false);
foreach (var attribute in attributes)
{
if (attribute is T attribute1)
{
attributesForMethodInfo.Add(attribute1);
}
}
cacheStorage[methodInfo] = attributesForMethodInfo;
return cacheStorage[methodInfo].ToArray();
}
private static List<MethodInfo> GetMethodsWithAttributeFromFixture(Type fixtureType, Type setUpType, Type[] returnTypes)
{
MethodInfo[] methodsWithAttribute = Reflect.GetMethodsWithAttribute(fixtureType, setUpType, true);
var methodsInfo = new List<MethodInfo>();
methodsInfo.AddRange(methodsWithAttribute.Where(method => returnTypes.Any(type => type == method.ReturnType)));
return methodsInfo;
}
protected abstract IEnumerator InvokeBefore(T action, Test test, UnityTestExecutionContext context);
protected abstract IEnumerator InvokeAfter(T action, Test test, UnityTestExecutionContext context);
protected virtual bool MoveBeforeEnumerator(IEnumerator enumerator, Test test)
{
return enumerator.MoveNext();
}
protected virtual bool MoveAfterEnumerator(IEnumerator enumerator, Test test)
{
return enumerator.MoveNext();
}
protected abstract BeforeAfterTestCommandState GetState(UnityTestExecutionContext context);
protected virtual bool AllowFrameSkipAfterAction(T action)
{
return true;
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
var unityContext = (UnityTestExecutionContext)context;
var state = GetState(unityContext);
if (state == null)
{
throw new Exception($"No state in context for {GetType().Name}.");
}
if(state.ShouldRestore)
{
state.ApplyContext(unityContext);
}
while (state.NextBeforeStepIndex < BeforeActions.Length)
{
var action = BeforeActions[state.NextBeforeStepIndex];
IEnumerator enumerator;
try
{
enumerator = EnumeratorHelper.UnpackNestedEnumerators(InvokeBefore(action, Test, unityContext));
EnumeratorHelper.SetEnumeratorPC(state.NextBeforeStepPc);
}
catch (Exception ex)
{
state.TestHasRun = true;
context.CurrentResult.RecordPrefixedException(m_BeforeErrorPrefix, ex);
break;
}
using (var logScope = new LogScope())
{
while (true)
{
try
{
if (!enumerator.MoveNext())
{
logScope.EvaluateLogScope(true);
break;
}
if (!AllowFrameSkipAfterAction(action)) // Evaluate the log scope right away for the commands where we do not yield
{
logScope.EvaluateLogScope(true);
}
if (enumerator.Current is IEditModeTestYieldInstruction)
{
if (unityContext.TestMode == TestPlatform.PlayMode)
{
throw new Exception($"PlayMode test are not allowed to yield {enumerator.Current.GetType().Name}");
}
if (EnumeratorHelper.IsRunningNestedEnumerator)
{
throw new Exception($"Nested enumerators are not allowed to yield {enumerator.Current.GetType().Name}");
}
}
}
catch (Exception ex)
{
state.TestHasRun = true;
context.CurrentResult.RecordPrefixedException(m_BeforeErrorPrefix, ex);
state.StoreContext(unityContext);
break;
}
if (!EnumeratorHelper.IsRunningNestedEnumerator)
{
// Only store the state in the main enumerator. Domain reloads are not supported from nested enumerators.
state.NextBeforeStepPc = EnumeratorHelper.GetEnumeratorPC();
state.StoreContext(unityContext);
}
if (!AllowFrameSkipAfterAction(action))
{
break;
}
yield return enumerator.Current;
}
}
state.NextBeforeStepIndex++;
state.NextBeforeStepPc = 0;
}
if (!state.TestHasRun)
{
state.ShouldRestore = false; // Any inner commands that can perform domain reloads are responsible for restoring the context
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
state.TestHasRun = true;
}
while (state.NextAfterStepIndex < AfterActions.Length)
{
state.TestAfterStarted = true;
var action = AfterActions[state.NextAfterStepIndex];
IEnumerator enumerator;
try
{
enumerator = EnumeratorHelper.UnpackNestedEnumerators(InvokeAfter(action, Test, unityContext));
EnumeratorHelper.SetEnumeratorPC(state.NextAfterStepPc);
}
catch (Exception ex)
{
context.CurrentResult.RecordPrefixedException(m_AfterErrorPrefix, ex);
state.StoreContext(unityContext);
break;
}
using (var logScope = new LogScope())
{
while (true)
{
try
{
if (!enumerator.MoveNext())
{
logScope.EvaluateLogScope(true);
break;
}
if (!AllowFrameSkipAfterAction(action)) // Evaluate the log scope right away for the commands where we do not yield
{
logScope.EvaluateLogScope(true);
}
if (enumerator.Current is IEditModeTestYieldInstruction)
{
if (unityContext.TestMode == TestPlatform.PlayMode)
{
throw new Exception($"PlayMode test are not allowed to yield {enumerator.Current.GetType().Name}");
}
if (EnumeratorHelper.IsRunningNestedEnumerator)
{
throw new Exception($"Nested enumerators are not allowed to yield {enumerator.Current.GetType().Name}");
}
}
}
catch (Exception ex)
{
context.CurrentResult.RecordPrefixedException(m_AfterErrorPrefix, ex);
state.StoreContext(unityContext);
break;
}
if (!EnumeratorHelper.IsRunningNestedEnumerator)
{
// Only store the state in the main enumerator. Domain reloads are not supported from nested enumerators.
state.NextAfterStepPc = EnumeratorHelper.GetEnumeratorPC();
state.StoreContext(unityContext);
}
if (!AllowFrameSkipAfterAction(action))
{
break;
}
yield return enumerator.Current;
}
}
state.NextAfterStepIndex++;
state.NextAfterStepPc = 0;
}
state.Reset();
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cbbca1d8a0434be4bbc7f165523763ac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,74 @@
using System;
using System.Reflection;
using System.Text;
using NUnit.Framework.Interfaces;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
[Serializable]
internal class BeforeAfterTestCommandState
{
private const BindingFlags Flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy;
public int NextBeforeStepIndex;
public int NextBeforeStepPc;
public int NextAfterStepIndex;
public int NextAfterStepPc;
public bool TestHasRun;
public TestStatus CurrentTestResultStatus;
public string CurrentTestResultLabel;
public FailureSite CurrentTestResultSite;
public string CurrentTestMessage;
public string CurrentTestStrackTrace;
public bool TestAfterStarted;
public string Output;
public long StartTicks;
public double StartTimeOA;
public bool ShouldRestore;
public void Reset()
{
NextBeforeStepIndex = 0;
NextBeforeStepPc = 0;
NextAfterStepIndex = 0;
NextAfterStepPc = 0;
TestHasRun = false;
CurrentTestResultStatus = TestStatus.Inconclusive;
CurrentTestResultLabel = null;
CurrentTestResultSite = default(FailureSite);
CurrentTestMessage = null;
CurrentTestStrackTrace = null;
TestAfterStarted = false;
Output = null;
StartTicks = 0;
StartTimeOA = 0;
ShouldRestore = false;
}
public void StoreContext(UnityTestExecutionContext context)
{
var result = context.CurrentResult;
CurrentTestResultStatus = result.ResultState.Status;
CurrentTestResultLabel = result.ResultState.Label;
CurrentTestResultSite = result.ResultState.Site;
CurrentTestMessage = result.Message;
CurrentTestStrackTrace = result.StackTrace;
Output = result.Output;
StartTicks = context.StartTicks;
StartTimeOA = context.StartTime.ToOADate();
ShouldRestore = true;
}
public void ApplyContext(UnityTestExecutionContext context)
{
var outputProp = context.CurrentResult.GetType().BaseType.GetField("_output", Flags);
var stringBuilder = (outputProp.GetValue(context.CurrentResult) as StringBuilder);
stringBuilder.Clear();
stringBuilder.Append(Output);
context.StartTicks = StartTicks;
context.StartTime = DateTime.FromOADate(StartTimeOA);
context.CurrentResult.SetResult(new ResultState(CurrentTestResultStatus, CurrentTestResultLabel, CurrentTestResultSite), CurrentTestMessage, CurrentTestStrackTrace);
ShouldRestore = false;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7f65567c9026afb4db5de3355accc636
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,34 @@
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableApplyChangesToContextCommand : ApplyChangesToContextCommand, IEnumerableTestMethodCommand
{
public EnumerableApplyChangesToContextCommand(TestCommand innerCommand, IEnumerable<IApplyToContext> changes)
: base(innerCommand, changes) {}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
ApplyChanges(context);
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3b4429eff9fcffb48b006e8edcc90338
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,54 @@
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableMaxTimeCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
{
private int maxTime;
public EnumerableMaxTimeCommand(MaxTimeCommand commandToReplace) : base(commandToReplace.GetInnerCommand())
{
maxTime = (int)typeof(MaxTimeCommand)
.GetField("maxTime", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(commandToReplace);
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new System.NotImplementedException("Use ExecuteEnumerable");
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
long timestamp = Stopwatch.GetTimestamp();
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
var duration = (Stopwatch.GetTimestamp() - timestamp) / (double) Stopwatch.Frequency;
var testResult = context.CurrentResult;
testResult.Duration = duration;
if (testResult.ResultState == ResultState.Success)
{
var durationInMilliseconds = duration * 1000.0;
if (durationInMilliseconds > maxTime)
testResult.SetResult(ResultState.Failure, string.Format("Elapsed time of {0}ms exceeds maximum of {1}ms", (object) durationInMilliseconds, (object) this.maxTime));
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aa5dd1a9432747fd89501213ba621de6
timeCreated: 1713961779
@@ -0,0 +1,66 @@
using System;
using System.Collections;
using System.Reflection;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableRepeatedTestCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
{
private int repeatCount;
public EnumerableRepeatedTestCommand(RepeatAttribute.RepeatedTestCommand commandToReplace) : base(commandToReplace.GetInnerCommand())
{
repeatCount = (int)typeof(RepeatAttribute.RepeatedTestCommand)
.GetField("repeatCount", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(commandToReplace);
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
var unityContext = (UnityTestExecutionContext)context;
int count = unityContext.EnumerableTestState.Repeat;
var firstCycleAfterResume = count > 0;
while (count < repeatCount || (firstCycleAfterResume && count <= repeatCount))
{
if (!firstCycleAfterResume)
{
count++;
}
firstCycleAfterResume = false;
unityContext.EnumerableTestState.Repeat = count;
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
if (context.CurrentResult.ResultState != ResultState.Success)
{
break;
}
}
unityContext.EnumerableTestState.Repeat = 0;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e273462feb9a65948826739f683cc9a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,67 @@
using System;
using System.Collections;
using System.Reflection;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableRetryTestCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
{
private int retryCount;
public EnumerableRetryTestCommand(RetryAttribute.RetryCommand commandToReplace) : base(commandToReplace.GetInnerCommand())
{
retryCount = (int)typeof(RetryAttribute.RetryCommand)
.GetField("_retryCount", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(commandToReplace);
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
var unityContext = (UnityTestExecutionContext)context;
int count = unityContext.EnumerableTestState.Retry;
var firstCycleAfterResume = count > 0;
while (count < retryCount || (firstCycleAfterResume && count <= retryCount))
{
if (!firstCycleAfterResume)
{
count++;
}
firstCycleAfterResume = false;
unityContext.EnumerableTestState.Retry = count;
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
if (context.CurrentResult.ResultState != ResultState.Failure)
{
break;
}
}
unityContext.EnumerableTestState.Retry = 0;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6de2f178a24cd2e48a0816cacd9a0583
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,58 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using Unity.Profiling;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class EnumerableSetUpTearDownCommand : BeforeAfterTestCommandBase<MethodInfo>
{
private static readonly Dictionary<Type, List<MethodInfo>> m_BeforeActionsCache = new Dictionary<Type, List<MethodInfo>>();
private static readonly Dictionary<Type, List<MethodInfo>> m_AfterActionsCache = new Dictionary<Type, List<MethodInfo>>();
public EnumerableSetUpTearDownCommand(TestCommand innerCommand)
: base(innerCommand, "SetUp", "TearDown")
{
using (new ProfilerMarker(nameof(EnumerableSetUpTearDownCommand)).Auto())
{
if (Test.TypeInfo.Type != null)
{
BeforeActions = GetActions(m_BeforeActionsCache, Test.TypeInfo.Type, typeof(UnitySetUpAttribute), new[] {typeof(IEnumerator)});
AfterActions = GetActions(m_AfterActionsCache, Test.TypeInfo.Type, typeof(UnityTearDownAttribute), new[] {typeof(IEnumerator)}).Reverse().ToArray();
}
}
}
protected override bool MoveAfterEnumerator(IEnumerator enumerator, Test test)
{
using (new ProfilerMarker(test.Name + ".TearDown").Auto())
return base.MoveAfterEnumerator(enumerator, test);
}
protected override bool MoveBeforeEnumerator(IEnumerator enumerator, Test test)
{
using (new ProfilerMarker(test.Name + ".Setup").Auto())
return base.MoveBeforeEnumerator(enumerator, test);
}
protected override IEnumerator InvokeBefore(MethodInfo action, Test test, UnityTestExecutionContext context)
{
return (IEnumerator)Reflect.InvokeMethod(action, context.TestObject);
}
protected override IEnumerator InvokeAfter(MethodInfo action, Test test, UnityTestExecutionContext context)
{
return (IEnumerator)Reflect.InvokeMethod(action, context.TestObject);
}
protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
{
return context.SetUpTearDownState;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dd85a35169d313840a0874aea1a28629
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,144 @@
using System;
using System.Collections;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using Unity.Profiling;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
using UnityEngine.TestTools.TestRunner;
namespace UnityEngine.TestTools
{
internal class EnumerableTestMethodCommand : TestCommand, IEnumerableTestMethodCommand
{
private readonly TestMethod testMethod;
public EnumerableTestMethodCommand(TestMethod testMethod)
: base(testMethod)
{
this.testMethod = testMethod;
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
var unityContext = (UnityTestExecutionContext) context;
yield return null;
IEnumerator currentExecutingTestEnumerator;
try
{
currentExecutingTestEnumerator = new TestEnumeratorWrapper(testMethod).GetEnumerator(context);
}
catch (Exception ex)
{
context.CurrentResult.RecordException(ex);
yield break;
}
if (currentExecutingTestEnumerator != null)
{
var testEnumeraterYieldInstruction = new TestEnumerator(context, currentExecutingTestEnumerator);
yield return testEnumeraterYieldInstruction;
var enumerator = testEnumeraterYieldInstruction.Execute();
var executingEnumerator = ExecuteEnumerableAndRecordExceptions(enumerator, new EnumeratorContext(context), unityContext);
while (AdvanceEnumerator(executingEnumerator))
{
yield return executingEnumerator.Current;
}
}
else
{
if (context.CurrentResult.ResultState != ResultState.Ignored)
{
context.CurrentResult.SetResult(ResultState.Success);
}
}
}
private bool AdvanceEnumerator(IEnumerator enumerator)
{
using (new ProfilerMarker(testMethod.MethodName).Auto())
return enumerator.MoveNext();
}
private IEnumerator ExecuteEnumerableAndRecordExceptions(IEnumerator enumerator, EnumeratorContext context, UnityTestExecutionContext unityContext)
{
while (true)
{
if (context.ExceptionWasRecorded)
{
break;
}
bool executionDone = false;
try
{
executionDone = !enumerator.MoveNext();
if (unityContext.TestMode == TestPlatform.PlayMode && enumerator.Current is IEditModeTestYieldInstruction)
{
throw new Exception($"PlayMode test are not allowed to yield {enumerator.Current.GetType().Name}");
}
}
catch (Exception ex)
{
context.RecordExceptionWithHint(ex);
break;
}
if (unityContext.HasTimedOut())
{
unityContext.CurrentResult.RecordException(new UnityTestTimeoutException(unityContext.TestCaseTimeout));
yield return new RestoreTestContextAfterDomainReload(); // If this is right after a domain reload, give the editor a chance to restore.
yield break;
}
if (executionDone)
{
break;
}
if (enumerator.Current is IEnumerator nestedEnumerator)
{
yield return ExecuteEnumerableAndRecordExceptions(nestedEnumerator, context, unityContext);
}
else
{
yield return enumerator.Current;
}
}
}
private class EnumeratorContext
{
private readonly ITestExecutionContext m_Context;
public EnumeratorContext(ITestExecutionContext context)
{
m_Context = context;
}
public bool ExceptionWasRecorded
{
get;
private set;
}
public void RecordExceptionWithHint(Exception ex)
{
if (ExceptionWasRecorded)
{
return;
}
m_Context.CurrentResult.RecordException(ex);
ExceptionWasRecorded = true;
}
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 19a6f000f81e24c4a826c1abd43e77c7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
using System;
namespace UnityEngine.TestTools
{
[Serializable]
internal class EnumerableTestState
{
public int Repeat;
public int Retry;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 356852e4738840b4b1ab533d3a66f0e1
timeCreated: 1606321047
@@ -0,0 +1,8 @@
namespace UnityEngine.TestTools
{
internal class IgnoreTest
{
public string test { get; set; }
public string ignoreComment { get; set; }
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9bbdc426fc0a48e1b66deaac7ea8f64c
timeCreated: 1675764691
@@ -0,0 +1,53 @@
using System;
using System.Collections;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class IgnoreTestCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
{
private ITest _test;
public IgnoreTestCommand(TestCommand innerCommand, ITest test) : base(innerCommand)
{
_test = test;
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
var ignoreTests = ((UnityTestExecutionContext) context).IgnoreTests;
if (ignoreTests != null && ignoreTests.Length > 0)
{
var fullName = _test.GetFullNameWithoutDllPath();
foreach (var ignoreTest in ignoreTests)
{
if (ignoreTest.test.Equals(fullName))
{
context.CurrentResult.SetResult(ResultState.Ignored,ignoreTest.ignoreComment);
yield break;
}
}
}
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e55eddf2afda488db58fb17f985fee99
timeCreated: 1675765192
@@ -0,0 +1,31 @@
using System;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class ImmediateEnumerableCommand : DelegatingTestCommand
{
public ImmediateEnumerableCommand(TestCommand innerCommand)
: base(innerCommand) {}
public override TestResult Execute(ITestExecutionContext context)
{
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
if (iterator != null)
{
throw new Exception("Only null can be yielded at this point.");
}
}
return context.CurrentResult;
}
return innerCommand.Execute(context);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8349e42a2b30c7a4abd8678c203428ba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,39 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class OuterUnityTestActionCommand : BeforeAfterTestCommandBase<IOuterUnityTestAction>
{
private static readonly Dictionary<MethodInfo, List<IOuterUnityTestAction>> m_TestActionsCache = new Dictionary<MethodInfo, List<IOuterUnityTestAction>>();
public OuterUnityTestActionCommand(TestCommand innerCommand)
: base(innerCommand, "BeforeTest", "AfterTest")
{
if (Test.TypeInfo.Type != null)
{
BeforeActions = GetTestActions(m_TestActionsCache, Test.Method.MethodInfo);
AfterActions = BeforeActions;
}
}
protected override IEnumerator InvokeBefore(IOuterUnityTestAction action, Test test, UnityTestExecutionContext context)
{
return action.BeforeTest(test);
}
protected override IEnumerator InvokeAfter(IOuterUnityTestAction action, Test test, UnityTestExecutionContext context)
{
return action.AfterTest(test);
}
protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
{
return context.OuterUnityTestActionState;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0d4fc309a0784294c8ab658b53b12320
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,65 @@
using System.Collections;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using System.Linq;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class ParametrizedIgnoreCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
{
private readonly TestCommand m_Command;
public object[] Arguments { get; }
public string Reason { get; }
public ParametrizedIgnoreCommand(TestCommand command, object[] arguments, string reason = "") : base(command)
{
m_Command = command;
Arguments = arguments;
Reason = reason;
}
public override TestResult Execute(ITestExecutionContext context)
{
if (context.CurrentTest is TestMethod testMethod)
{
var isIgnored = testMethod.parms.Arguments.SequenceEqual(Arguments);
if (isIgnored)
{
context.CurrentResult.SetResult(ResultState.Ignored, Reason);
return context.CurrentResult;
}
}
return m_Command.Execute(context);
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
if (context.CurrentTest is TestMethod testMethod)
{
var isIgnored = testMethod.parms.Arguments.SequenceEqual(Arguments);
if (isIgnored)
{
context.CurrentResult.SetResult(ResultState.Ignored, Reason);
yield break;
}
}
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 74987b94d22047d8b286a727906b7019
timeCreated: 1699350178
@@ -0,0 +1,85 @@
using System;
using System.Collections;
using System.Diagnostics;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class RepeatCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
{
public RepeatCommand(TestCommand innerCommand)
: base(innerCommand)
{
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
var unityContext = (UnityTestExecutionContext)context;
if (unityContext.RetryRepeatState?.GetHashCode() == null)
{
unityContext.RetryRepeatState = new EnumerableTestState();
}
while(unityContext.RetryRepeatState.Repeat < unityContext.RepeatCount + 1)
{
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
if (context.CurrentResult.ResultState != ResultState.Success)
{
unityContext.RetryRepeatState.Repeat++;
break;
}
if (unityContext.RetryRepeatState.Repeat < unityContext.RepeatCount)
{
ReportTestFinishStartPair(unityContext);
}
unityContext.RetryRepeatState.Repeat++;
}
SetIterationProperty(unityContext, unityContext.RetryRepeatState.Repeat-1);
unityContext.RetryRepeatState.Repeat = 0;
}
private static void ReportTestFinishStartPair(UnityTestExecutionContext unityContext)
{
unityContext.CurrentResult.StartTime = unityContext.StartTime;
unityContext.CurrentResult.EndTime = DateTime.UtcNow;
long tickCount = Stopwatch.GetTimestamp() - unityContext.StartTicks;
double seconds = (double) tickCount / Stopwatch.Frequency;
unityContext.CurrentResult.Duration = seconds;
SetIterationProperty(unityContext, unityContext.RetryRepeatState.Repeat);
unityContext.Listener.TestFinished(unityContext.CurrentResult);
// Start new test iteration
unityContext.CurrentResult = unityContext.CurrentTest.MakeTestResult();
unityContext.StartTime = DateTime.UtcNow;
unityContext.StartTicks = Stopwatch.GetTimestamp();
unityContext.Listener.TestStarted(unityContext.CurrentTest);
}
private static void SetIterationProperty(UnityTestExecutionContext unityContext, int iteration)
{
unityContext.CurrentResult.Test.Properties.Set("repeatIteration", iteration);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 851f94140ec64b7db846948429a87f01
timeCreated: 1680611750
@@ -0,0 +1,86 @@
using System;
using System.Collections;
using System.Diagnostics;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
using UnityEngine.TestRunner.TestProtocol;
namespace UnityEngine.TestTools
{
internal class RetryCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
{
public RetryCommand(TestCommand innerCommand)
: base(innerCommand)
{
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
var unityContext = (UnityTestExecutionContext)context;
if (unityContext.RetryRepeatState?.GetHashCode() == null)
{
unityContext.RetryRepeatState = new EnumerableTestState();
}
while(unityContext.RetryRepeatState.Retry < unityContext.RetryCount + 1)
{
if (innerCommand is IEnumerableTestMethodCommand)
{
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
}
else
{
context.CurrentResult = innerCommand.Execute(context);
}
if (context.CurrentResult.ResultState != ResultState.Failure || context.CurrentResult.ResultState == ResultState.Error)
{
unityContext.RetryRepeatState.Retry++;
break;
}
if (unityContext.Automated && unityContext.RetryRepeatState.Retry < unityContext.RetryCount)
{
ReportTestFinishStartPair(unityContext);
}
unityContext.RetryRepeatState.Retry++;
}
SetIterationProperty(unityContext, unityContext.RetryRepeatState.Retry - 1);
unityContext.RetryRepeatState.Retry = 0;
}
private static void ReportTestFinishStartPair(UnityTestExecutionContext unityContext)
{
unityContext.CurrentResult.StartTime = unityContext.StartTime;
unityContext.CurrentResult.EndTime = DateTime.UtcNow;
long tickCount = Stopwatch.GetTimestamp() - unityContext.StartTicks;
double seconds = (double) tickCount / Stopwatch.Frequency;
unityContext.CurrentResult.Duration = seconds;
SetIterationProperty(unityContext, unityContext.RetryRepeatState.Retry);
unityContext.Listener.TestFinished(unityContext.CurrentResult);
// Start new test iteration
unityContext.CurrentResult = unityContext.CurrentTest.MakeTestResult();
unityContext.StartTime = DateTime.UtcNow;
unityContext.StartTicks = Stopwatch.GetTimestamp();
unityContext.Listener.TestStarted(unityContext.CurrentTest);
}
private static void SetIterationProperty(UnityTestExecutionContext unityContext, int iteration)
{
unityContext.CurrentResult.Test.Properties.Set("retryIteration", iteration);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f180b12c4cff494c91056caa03f9c109
timeCreated: 1677662056
@@ -0,0 +1,107 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.ExceptionServices;
using System.Threading.Tasks;
using NUnit.Framework;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using Unity.Profiling;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class SetUpTearDownCommand : BeforeAfterTestCommandBase<MethodInfo>
{
private static readonly Dictionary<Type, List<MethodInfo>> m_BeforeActionsCache = new Dictionary<Type, List<MethodInfo>>();
private static readonly Dictionary<Type, List<MethodInfo>> m_AfterActionsCache = new Dictionary<Type, List<MethodInfo>>();
public SetUpTearDownCommand(TestCommand innerCommand)
: base(innerCommand, "SetUp", "TearDown")
{
using (new ProfilerMarker(nameof(SetUpTearDownCommand)).Auto())
{
if (Test.TypeInfo.Type != null)
{
BeforeActions = GetActions(m_BeforeActionsCache, Test.TypeInfo.Type, typeof(SetUpAttribute), new[] {typeof(void), typeof(Task)});
AfterActions = GetActions(m_AfterActionsCache, Test.TypeInfo.Type, typeof(TearDownAttribute), new[] {typeof(void), typeof(Task)}).Reverse().ToArray();
}
}
}
protected override bool AllowFrameSkipAfterAction(MethodInfo action)
{
return action.ReturnType == typeof(Task);
}
protected override IEnumerator InvokeBefore(MethodInfo action, Test test, UnityTestExecutionContext context)
{
if (action.ReturnType == typeof(Task))
{
Task task;
using (new ProfilerMarker(test.Name + ".Setup").Auto())
task = HandleTaskCommand(action, context);
while (!task.IsCompleted)
{
yield return null;
}
if (task.IsFaulted)
{
ExceptionDispatchInfo.Capture(task.Exception.InnerExceptions.Count == 1 ? task.Exception.InnerException : task.Exception).Throw();
}
}
else
{
using (new ProfilerMarker(test.Name + ".Setup").Auto())
Reflect.InvokeMethod(action, context.TestObject);
yield return null;
}
}
protected override IEnumerator InvokeAfter(MethodInfo action, Test test, UnityTestExecutionContext context)
{
if (action.ReturnType == typeof(Task))
{
Task task;
using (new ProfilerMarker(test.Name + ".TearDown").Auto())
task = HandleTaskCommand(action, context);
while (!task.IsCompleted)
{
yield return null;
}
if (task.IsFaulted)
{
ExceptionDispatchInfo.Capture(task.Exception.InnerExceptions.Count == 1 ? task.Exception.InnerException : task.Exception).Throw();
}
}
else
{
using (new ProfilerMarker(test.Name + ".TearDown").Auto())
Reflect.InvokeMethod(action, context.TestObject);
yield return null;
}
}
private Task HandleTaskCommand(MethodInfo action, UnityTestExecutionContext context)
{
try
{
return Reflect.InvokeMethod(action, context.TestObject) as Task;
}
catch (TargetInvocationException e)
{
throw e;
}
}
protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
{
// Normal Setup/Teardown does not support domain reloads and will not need a persisted state.
return new BeforeAfterTestCommandState();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e0db3f3921670cd4ca2e925737c3fba4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,58 @@
using System;
using System.Collections;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEditor;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
#if UNITY_EDITOR
using UnityEditorInternal;
#endif
namespace UnityEngine.TestTools
{
internal class StrictCheckCommand : DelegatingTestCommand, IEnumerableTestMethodCommand
{
public StrictCheckCommand(TestCommand innerCommand) : base(innerCommand)
{
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException();
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
var unityContext = UnityTestExecutionContext.CurrentContext;
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable)
{
yield return iterator;
}
if (!unityContext.FeatureFlags.strictDomainReload)
{
yield break;
}
// Refreshing the asset database before the check, to ensure that
// no potential pending domain reloads propagate to the following test
// (due to ex. creation or deletion of asset files in the TearDown of a test).
#if UNITY_EDITOR
AssetDatabase.Refresh();
#endif
if (isDomainReloadPending())
{
context.CurrentResult.SetResult(ResultState.Failure, "A pending domain reload was detected.");
}
}
private static bool isDomainReloadPending()
{
#if UNITY_EDITOR
return (InternalEditorUtility.IsScriptReloadRequested() || EditorApplication.isCompiling);
#else
return false;
#endif
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cc294d4e597b4ba5acf52ad834cce210
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,110 @@
using System;
using System.Collections;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using Unity.Profiling;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
using UnityEngine.TestTools.TestRunner;
namespace UnityEngine.TestTools
{
internal class TaskTestMethodCommand : TestCommand, IEnumerableTestMethodCommand
{
private readonly TestMethod testMethod;
public TaskTestMethodCommand(TestMethod testMethod)
: base(testMethod)
{
this.testMethod = testMethod;
}
public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{
yield return null;
IEnumerator currentExecutingTestEnumerator;
try
{
currentExecutingTestEnumerator = new TestTaskWrapper(testMethod).Execute(context);
}
catch (Exception ex)
{
context.CurrentResult.RecordException(ex);
yield break;
}
if (currentExecutingTestEnumerator != null)
{
var testEnumeratorYieldInstruction = new TestEnumerator(context, currentExecutingTestEnumerator);
yield return testEnumeratorYieldInstruction;
var enumerator = testEnumeratorYieldInstruction.Execute();
var executingEnumerator = ExecuteEnumerableAndRecordExceptions(enumerator, context);
bool enumeratorDone = false;
while (enumeratorDone == false)
{
enumeratorDone = !AdvanceEnumerator(executingEnumerator);
if (((UnityTestExecutionContext) context).HasTimedOut())
{
context.CurrentResult.RecordException(new UnityTestTimeoutException(context.TestCaseTimeout));
yield break;
}
yield return executingEnumerator.Current;
}
}
else
{
if (context.CurrentResult.ResultState != ResultState.Ignored)
{
context.CurrentResult.SetResult(ResultState.Success);
}
}
}
private bool AdvanceEnumerator(IEnumerator enumerator)
{
using (new ProfilerMarker(testMethod.MethodName).Auto())
{
return enumerator.MoveNext();
}
}
private static IEnumerator ExecuteEnumerableAndRecordExceptions(IEnumerator enumerator, ITestExecutionContext context)
{
while (true)
{
try
{
if (!enumerator.MoveNext())
{
break;
}
}
catch (Exception ex)
{
context.CurrentResult.RecordException(ex);
break;
}
if (enumerator.Current is IEnumerator)
{
var current = (IEnumerator)enumerator.Current;
yield return ExecuteEnumerableAndRecordExceptions(current, context);
}
else
{
yield return enumerator.Current;
}
}
}
public override TestResult Execute(ITestExecutionContext context)
{
throw new NotImplementedException("Use ExecuteEnumerable");
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ad85854b14d4140d88447bdce2fac91f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,49 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using NUnit.Framework;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools
{
internal class TestActionCommand : BeforeAfterTestCommandBase<ITestAction>
{
private static readonly Dictionary<MethodInfo, List<ITestAction>> m_TestActionsCache = new Dictionary<MethodInfo, List<ITestAction>>();
public TestActionCommand(TestCommand innerCommand)
: base(innerCommand, "BeforeTest", "AfterTest")
{
if (Test.TypeInfo.Type != null)
{
BeforeActions = GetTestActions(m_TestActionsCache, Test.Method.MethodInfo);
AfterActions = BeforeActions;
}
}
protected override bool AllowFrameSkipAfterAction(ITestAction action)
{
return false;
}
protected override IEnumerator InvokeBefore(ITestAction action, Test test, UnityTestExecutionContext context)
{
action.BeforeTest(test);
yield return null;
}
protected override IEnumerator InvokeAfter(ITestAction action, Test test, UnityTestExecutionContext context)
{
action.AfterTest(test);
yield return null;
}
protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
{
// TestActionCommand does not support domain reloads and will not need a persisted state.
return new BeforeAfterTestCommandState();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2de8ba3b840049641897e0da7ce1d5cd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
using System;
using System.Collections;
namespace UnityEngine.TestTools
{
internal class TestCommandPcHelper
{
public virtual void SetEnumeratorPC(IEnumerator enumerator, int pc)
{
// Noop implementation used in playmode.
}
public virtual int GetEnumeratorPC(IEnumerator enumerator)
{
return 0;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 33e6b78c96bb0694e96383e3c56b7b54
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,30 @@
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands;
using Unity.Profiling;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
using UnityEngine.TestTools.TestRunner;
namespace UnityEngine.TestTools
{
internal class UnityTestMethodCommand : TestMethodCommand
{
public UnityTestMethodCommand(TestMethod testMethod)
: base(testMethod) {}
public override TestResult Execute(ITestExecutionContext context)
{
using (new ProfilerMarker(Test.FullName).Auto())
{
var result = base.Execute(context);
if (((UnityTestExecutionContext) context).HasTimedOut())
{
context.CurrentResult.RecordException(new UnityTestTimeoutException(context.TestCaseTimeout));
}
return result;
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d2ca9278c9dd49df877d622d0f657ecf
timeCreated: 1614093428