Commit af571a61 authored by BlackAngle233's avatar BlackAngle233
Browse files

212

parent 1d9b5391
fileFormatVersion: 2 fileFormatVersion: 2
guid: c82a8473f4a8f7b42a004c91e06d2f2b guid: c82a8473f4a8f7b42a004c91e06d2f2b
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
using System; using System;
using System.Collections; using System.Collections;
using NUnit.Framework; using NUnit.Framework;
using NUnit.Framework.Interfaces; using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal; using NUnit.Framework.Internal;
namespace UnityEngine.TestTools namespace UnityEngine.TestTools
{ {
internal class TestEnumerator internal class TestEnumerator
{ {
private readonly ITestExecutionContext m_Context; private readonly ITestExecutionContext m_Context;
private static IEnumerator m_TestEnumerator; private static IEnumerator m_TestEnumerator;
public static IEnumerator Enumerator { get { return m_TestEnumerator; } } public static IEnumerator Enumerator { get { return m_TestEnumerator; } }
public TestEnumerator(ITestExecutionContext context, IEnumerator testEnumerator) public TestEnumerator(ITestExecutionContext context, IEnumerator testEnumerator)
{ {
m_Context = context; m_Context = context;
m_TestEnumerator = testEnumerator; m_TestEnumerator = testEnumerator;
} }
public IEnumerator Execute() public IEnumerator Execute()
{ {
m_Context.CurrentResult.SetResult(ResultState.Success); m_Context.CurrentResult.SetResult(ResultState.Success);
while (true) while (true)
{ {
object current = null; object current = null;
try try
{ {
if (!m_TestEnumerator.MoveNext()) if (!m_TestEnumerator.MoveNext())
{ {
yield break; yield break;
} }
if (!m_Context.CurrentResult.ResultState.Equals(ResultState.Success)) if (!m_Context.CurrentResult.ResultState.Equals(ResultState.Success))
{ {
yield break; yield break;
} }
current = m_TestEnumerator.Current; current = m_TestEnumerator.Current;
} }
catch (Exception exception) catch (Exception exception)
{ {
m_Context.CurrentResult.RecordException(exception); m_Context.CurrentResult.RecordException(exception);
yield break; yield break;
} }
yield return current; yield return current;
} }
} }
} }
} }
fileFormatVersion: 2 fileFormatVersion: 2
guid: 750aad009559b814dbc27001341fc1c3 guid: 750aad009559b814dbc27001341fc1c3
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
using System; using System;
namespace UnityEngine.TestTools namespace UnityEngine.TestTools
{ {
/// <summary> /// <summary>
/// The presence of this attribute will cause the test runner to require that every single log is expected. By /// The presence of this attribute will cause the test runner to require that every single log is expected. By
/// default, the runner will only automatically fail on any error logs, so this adds warnings and infos as well. /// default, the runner will only automatically fail on any error logs, so this adds warnings and infos as well.
/// It is the same as calling `LogAssert.NoUnexpectedReceived()` at the bottom of every affected test. /// It is the same as calling `LogAssert.NoUnexpectedReceived()` at the bottom of every affected test.
/// ///
/// This attribute can be applied to test assemblies (will affect every test in the assembly), fixtures (will /// This attribute can be applied to test assemblies (will affect every test in the assembly), fixtures (will
/// affect every test in the fixture), or on individual test methods. It is also automatically inherited from base /// affect every test in the fixture), or on individual test methods. It is also automatically inherited from base
/// fixtures. /// fixtures.
/// ///
/// The MustExpect property (on by default) lets you selectively enable or disable the higher level value. For /// The MustExpect property (on by default) lets you selectively enable or disable the higher level value. For
/// example when migrating an assembly to this more strict checking method, you might attach /// example when migrating an assembly to this more strict checking method, you might attach
/// `[assembly:TestMustExpectAllLogs]` to the assembly itself, but then whitelist failing fixtures and test methods /// `[assembly:TestMustExpectAllLogs]` to the assembly itself, but then whitelist failing fixtures and test methods
/// with `[TestMustExpectAllLogs(MustExpect=false)]` until they can be migrated. This also means new tests in that /// with `[TestMustExpectAllLogs(MustExpect=false)]` until they can be migrated. This also means new tests in that
/// assembly would be required to have the more strict checking. /// assembly would be required to have the more strict checking.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
public class TestMustExpectAllLogsAttribute : Attribute public class TestMustExpectAllLogsAttribute : Attribute
{ {
public TestMustExpectAllLogsAttribute(bool mustExpect = true) public TestMustExpectAllLogsAttribute(bool mustExpect = true)
=> MustExpect = mustExpect; => MustExpect = mustExpect;
public bool MustExpect { get; } public bool MustExpect { get; }
} }
} }
fileFormatVersion: 2 fileFormatVersion: 2
guid: 3803f736886e77842995ddbc3531afaa guid: 3803f736886e77842995ddbc3531afaa
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework.Interfaces; using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal.Builders; using NUnit.Framework.Internal.Builders;
namespace UnityEngine.TestTools namespace UnityEngine.TestTools
{ {
internal class UnityCombinatorialStrategy : CombinatorialStrategy, ICombiningStrategy internal class UnityCombinatorialStrategy : CombinatorialStrategy, ICombiningStrategy
{ {
public new IEnumerable<ITestCaseData> GetTestCases(IEnumerable[] sources) public new IEnumerable<ITestCaseData> GetTestCases(IEnumerable[] sources)
{ {
var testCases = base.GetTestCases(sources); var testCases = base.GetTestCases(sources);
foreach (var testCase in testCases) foreach (var testCase in testCases)
{ {
testCase.GetType().GetProperty("ExpectedResult").SetValue(testCase, new object(), null); testCase.GetType().GetProperty("ExpectedResult").SetValue(testCase, new object(), null);
} }
return testCases; return testCases;
} }
} }
} }
fileFormatVersion: 2 fileFormatVersion: 2
guid: 7af6ac3e6b51b8d4aab04adc85b8de2f guid: 7af6ac3e6b51b8d4aab04adc85b8de2f
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using NUnit.Framework.Interfaces; using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal; using NUnit.Framework.Internal;
namespace UnityEngine.TestTools namespace UnityEngine.TestTools
{ {
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = false)] [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
public class UnityPlatformAttribute : NUnitAttribute, IApplyToTest public class UnityPlatformAttribute : NUnitAttribute, IApplyToTest
{ {
public RuntimePlatform[] include { get; set; } public RuntimePlatform[] include { get; set; }
public RuntimePlatform[] exclude { get; set; } public RuntimePlatform[] exclude { get; set; }
private string m_skippedReason; private string m_skippedReason;
public UnityPlatformAttribute() public UnityPlatformAttribute()
{ {
include = new List<RuntimePlatform>().ToArray(); include = new List<RuntimePlatform>().ToArray();
exclude = new List<RuntimePlatform>().ToArray(); exclude = new List<RuntimePlatform>().ToArray();
} }
public UnityPlatformAttribute(params RuntimePlatform[] include) public UnityPlatformAttribute(params RuntimePlatform[] include)
: this() : this()
{ {
this.include = include; this.include = include;
} }
public void ApplyToTest(Test test) public void ApplyToTest(Test test)
{ {
if (test.RunState == RunState.NotRunnable || test.RunState == RunState.Ignored || IsPlatformSupported(Application.platform)) if (test.RunState == RunState.NotRunnable || test.RunState == RunState.Ignored || IsPlatformSupported(Application.platform))
{ {
return; return;
} }
test.RunState = RunState.Skipped; test.RunState = RunState.Skipped;
test.Properties.Add("_SKIPREASON", m_skippedReason); test.Properties.Add("_SKIPREASON", m_skippedReason);
} }
internal bool IsPlatformSupported(RuntimePlatform testTargetPlatform) internal bool IsPlatformSupported(RuntimePlatform testTargetPlatform)
{ {
if (include.Any() && !include.Any(x => x == testTargetPlatform)) if (include.Any() && !include.Any(x => x == testTargetPlatform))
{ {
m_skippedReason = string.Format("Only supported on {0}", string.Join(", ", include.Select(x => x.ToString()).ToArray())); m_skippedReason = string.Format("Only supported on {0}", string.Join(", ", include.Select(x => x.ToString()).ToArray()));
return false; return false;
} }
if (exclude.Any(x => x == testTargetPlatform)) if (exclude.Any(x => x == testTargetPlatform))
{ {
m_skippedReason = string.Format("Not supported on {0}", string.Join(", ", include.Select(x => x.ToString()).ToArray())); m_skippedReason = string.Format("Not supported on {0}", string.Join(", ", include.Select(x => x.ToString()).ToArray()));
return false; return false;
} }
return true; return true;
} }
} }
} }
fileFormatVersion: 2 fileFormatVersion: 2
guid: 5440c1153b397e14c9c7b1d6eb83b9f9 guid: 5440c1153b397e14c9c7b1d6eb83b9f9
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
using System; using System;
using NUnit.Framework; using NUnit.Framework;
namespace UnityEngine.TestTools namespace UnityEngine.TestTools
{ {
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public class UnitySetUpAttribute : NUnitAttribute public class UnitySetUpAttribute : NUnitAttribute
{ {
} }
} }
fileFormatVersion: 2 fileFormatVersion: 2
guid: cc6401f13df54ba44bfd7cdc93c7d64d guid: cc6401f13df54ba44bfd7cdc93c7d64d
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
using System; using System;
using NUnit.Framework; using NUnit.Framework;
namespace UnityEngine.TestTools namespace UnityEngine.TestTools
{ {
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public class UnityTearDownAttribute : NUnitAttribute public class UnityTearDownAttribute : NUnitAttribute
{ {
} }
} }
fileFormatVersion: 2 fileFormatVersion: 2
guid: 600f4b74746dbf944901257f81a8af6d guid: 600f4b74746dbf944901257f81a8af6d
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
using System; using System;
using NUnit.Framework; using NUnit.Framework;
using NUnit.Framework.Internal.Commands; using NUnit.Framework.Internal.Commands;
using NUnit.Framework.Interfaces; using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal; using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Builders; using NUnit.Framework.Internal.Builders;
using UnityEngine.TestRunner.NUnitExtensions.Runner; using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEngine.TestTools namespace UnityEngine.TestTools
{ {
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public class UnityTestAttribute : CombiningStrategyAttribute, ISimpleTestBuilder, IImplyFixture public class UnityTestAttribute : CombiningStrategyAttribute, ISimpleTestBuilder, IImplyFixture
{ {
public UnityTestAttribute() : base(new UnityCombinatorialStrategy(), new ParameterDataSourceProvider()) {} public UnityTestAttribute() : base(new UnityCombinatorialStrategy(), new ParameterDataSourceProvider()) {}
private readonly NUnitTestCaseBuilder _builder = new NUnitTestCaseBuilder(); private readonly NUnitTestCaseBuilder _builder = new NUnitTestCaseBuilder();
TestMethod ISimpleTestBuilder.BuildFrom(IMethodInfo method, Test suite) TestMethod ISimpleTestBuilder.BuildFrom(IMethodInfo method, Test suite)
{ {
TestCaseParameters parms = new TestCaseParameters TestCaseParameters parms = new TestCaseParameters
{ {
ExpectedResult = new object(), ExpectedResult = new object(),
HasExpectedResult = true HasExpectedResult = true
}; };
var t = _builder.BuildTestMethod(method, suite, parms); var t = _builder.BuildTestMethod(method, suite, parms);
if (t.parms != null) if (t.parms != null)
t.parms.HasExpectedResult = false; t.parms.HasExpectedResult = false;
return t; return t;
} }
} }
} }
fileFormatVersion: 2 fileFormatVersion: 2
guid: fedb0f9e5006b1943abae52f52f08a1a guid: fedb0f9e5006b1943abae52f52f08a1a
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
using System; using System;
using System.Threading; using System.Threading;
using NUnit.Framework.Internal; using NUnit.Framework.Internal;
namespace UnityEngine.TestTools.NUnitExtensions namespace UnityEngine.TestTools.NUnitExtensions
{ {
internal abstract class BaseDelegator internal abstract class BaseDelegator
{ {
protected ManualResetEvent m_Signal = new ManualResetEvent(false); protected ManualResetEvent m_Signal = new ManualResetEvent(false);
protected object m_Result; protected object m_Result;
protected Exception m_Exception; protected Exception m_Exception;
protected ITestExecutionContext m_Context; protected ITestExecutionContext m_Context;
protected bool m_Aborted; protected bool m_Aborted;
protected object HandleResult() protected object HandleResult()
{ {
SetCurrentTestContext(); SetCurrentTestContext();
if (m_Exception != null) if (m_Exception != null)
{ {
var temp = m_Exception; var temp = m_Exception;
m_Exception = null; m_Exception = null;
throw temp; throw temp;
} }
var tempResult = m_Result; var tempResult = m_Result;
m_Result = null; m_Result = null;
return tempResult; return tempResult;
} }
protected void WaitForSignal() protected void WaitForSignal()
{ {
while (!m_Signal.WaitOne(100)) while (!m_Signal.WaitOne(100))
{ {
if (m_Aborted) if (m_Aborted)
{ {
m_Aborted = false; m_Aborted = false;
Reflect.MethodCallWrapper = null; Reflect.MethodCallWrapper = null;
throw new Exception(); throw new Exception();
} }
} }
} }
public void Abort() public void Abort()
{ {
m_Aborted = true; m_Aborted = true;
} }
protected void SetCurrentTestContext() protected void SetCurrentTestContext()
{ {
var prop = typeof(TestExecutionContext).GetProperty("CurrentContext"); var prop = typeof(TestExecutionContext).GetProperty("CurrentContext");
if (prop != null) if (prop != null)
{ {
prop.SetValue(null, m_Context, null); prop.SetValue(null, m_Context, null);
} }
} }
} }
} }
fileFormatVersion: 2 fileFormatVersion: 2
guid: 37cea569bfefafe49a1513c4d7f0e9eb guid: 37cea569bfefafe49a1513c4d7f0e9eb
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
fileFormatVersion: 2 fileFormatVersion: 2
guid: 6b72875690e0f7343911e06af3145bd5 guid: 6b72875690e0f7343911e06af3145bd5
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
using System; using System;
using System.Collections; using System.Collections;
using System.Linq; using System.Linq;
using NUnit.Framework.Interfaces; using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal; using NUnit.Framework.Internal;
using NUnit.Framework.Internal.Commands; using NUnit.Framework.Internal.Commands;
using UnityEngine.TestRunner.NUnitExtensions; using UnityEngine.TestRunner.NUnitExtensions;
using UnityEngine.TestRunner.NUnitExtensions.Runner; using UnityEngine.TestRunner.NUnitExtensions.Runner;
using UnityEngine.TestTools.Logging; using UnityEngine.TestTools.Logging;
using UnityEngine.TestTools.TestRunner; using UnityEngine.TestTools.TestRunner;
namespace UnityEngine.TestTools namespace UnityEngine.TestTools
{ {
internal abstract class BeforeAfterTestCommandBase<T> : DelegatingTestCommand, IEnumerableTestMethodCommand internal abstract class BeforeAfterTestCommandBase<T> : DelegatingTestCommand, IEnumerableTestMethodCommand
{ {
private string m_BeforeErrorPrefix; private string m_BeforeErrorPrefix;
private string m_AfterErrorPrefix; private string m_AfterErrorPrefix;
private bool m_SkipYieldAfterActions; private bool m_SkipYieldAfterActions;
protected BeforeAfterTestCommandBase(TestCommand innerCommand, string beforeErrorPrefix, string afterErrorPrefix, bool skipYieldAfterActions = false) protected BeforeAfterTestCommandBase(TestCommand innerCommand, string beforeErrorPrefix, string afterErrorPrefix, bool skipYieldAfterActions = false)
: base(innerCommand) : base(innerCommand)
{ {
m_BeforeErrorPrefix = beforeErrorPrefix; m_BeforeErrorPrefix = beforeErrorPrefix;
m_AfterErrorPrefix = afterErrorPrefix; m_AfterErrorPrefix = afterErrorPrefix;
m_SkipYieldAfterActions = skipYieldAfterActions; m_SkipYieldAfterActions = skipYieldAfterActions;
} }
protected T[] BeforeActions = new T[0]; protected T[] BeforeActions = new T[0];
protected T[] AfterActions = new T[0]; protected T[] AfterActions = new T[0];
protected abstract IEnumerator InvokeBefore(T action, Test test, UnityTestExecutionContext context); protected abstract IEnumerator InvokeBefore(T action, Test test, UnityTestExecutionContext context);
protected abstract IEnumerator InvokeAfter(T action, Test test, UnityTestExecutionContext context); protected abstract IEnumerator InvokeAfter(T action, Test test, UnityTestExecutionContext context);
protected abstract BeforeAfterTestCommandState GetState(UnityTestExecutionContext context); protected abstract BeforeAfterTestCommandState GetState(UnityTestExecutionContext context);
public IEnumerable ExecuteEnumerable(ITestExecutionContext context) public IEnumerable ExecuteEnumerable(ITestExecutionContext context)
{ {
var unityContext = (UnityTestExecutionContext)context; var unityContext = (UnityTestExecutionContext)context;
var state = GetState(unityContext); var state = GetState(unityContext);
if (state == null) if (state == null)
{ {
// We do not expect a state to exist in playmode // We do not expect a state to exist in playmode
state = ScriptableObject.CreateInstance<BeforeAfterTestCommandState>(); state = ScriptableObject.CreateInstance<BeforeAfterTestCommandState>();
} }
state.ApplyTestResult(context.CurrentResult); state.ApplyTestResult(context.CurrentResult);
while (state.NextBeforeStepIndex < BeforeActions.Length) while (state.NextBeforeStepIndex < BeforeActions.Length)
{ {
var action = BeforeActions[state.NextBeforeStepIndex]; var action = BeforeActions[state.NextBeforeStepIndex];
var enumerator = InvokeBefore(action, Test, unityContext); var enumerator = InvokeBefore(action, Test, unityContext);
ActivePcHelper.SetEnumeratorPC(enumerator, state.NextBeforeStepPc); ActivePcHelper.SetEnumeratorPC(enumerator, state.NextBeforeStepPc);
using (var logScope = new LogScope()) using (var logScope = new LogScope())
{ {
while (true) while (true)
{ {
try try
{ {
if (!enumerator.MoveNext()) if (!enumerator.MoveNext())
{ {
break; break;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
state.TestHasRun = true; state.TestHasRun = true;
context.CurrentResult.RecordPrefixedException(m_BeforeErrorPrefix, ex); context.CurrentResult.RecordPrefixedException(m_BeforeErrorPrefix, ex);
state.StoreTestResult(context.CurrentResult); state.StoreTestResult(context.CurrentResult);
break; break;
} }
state.NextBeforeStepPc = ActivePcHelper.GetEnumeratorPC(enumerator); state.NextBeforeStepPc = ActivePcHelper.GetEnumeratorPC(enumerator);
state.StoreTestResult(context.CurrentResult); state.StoreTestResult(context.CurrentResult);
if (m_SkipYieldAfterActions) if (m_SkipYieldAfterActions)
{ {
break; break;
} }
else else
{ {
yield return enumerator.Current; yield return enumerator.Current;
} }
} }
if (logScope.AnyFailingLogs()) if (logScope.AnyFailingLogs())
{ {
state.TestHasRun = true; state.TestHasRun = true;
context.CurrentResult.RecordPrefixedError(m_BeforeErrorPrefix, new UnhandledLogMessageException(logScope.FailingLogs.First()).Message); context.CurrentResult.RecordPrefixedError(m_BeforeErrorPrefix, new UnhandledLogMessageException(logScope.FailingLogs.First()).Message);
state.StoreTestResult(context.CurrentResult); state.StoreTestResult(context.CurrentResult);
} }
} }
state.NextBeforeStepIndex++; state.NextBeforeStepIndex++;
state.NextBeforeStepPc = 0; state.NextBeforeStepPc = 0;
} }
if (!state.TestHasRun) if (!state.TestHasRun)
{ {
if (innerCommand is IEnumerableTestMethodCommand) if (innerCommand is IEnumerableTestMethodCommand)
{ {
var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context); var executeEnumerable = ((IEnumerableTestMethodCommand)innerCommand).ExecuteEnumerable(context);
foreach (var iterator in executeEnumerable) foreach (var iterator in executeEnumerable)
{ {
state.StoreTestResult(context.CurrentResult); state.StoreTestResult(context.CurrentResult);
yield return iterator; yield return iterator;
} }
} }
else else
{ {
context.CurrentResult = innerCommand.Execute(context); context.CurrentResult = innerCommand.Execute(context);
state.StoreTestResult(context.CurrentResult); state.StoreTestResult(context.CurrentResult);
} }
state.TestHasRun = true; state.TestHasRun = true;
} }
while (state.NextAfterStepIndex < AfterActions.Length) while (state.NextAfterStepIndex < AfterActions.Length)
{ {
state.TestAfterStarted = true; state.TestAfterStarted = true;
var action = AfterActions[state.NextAfterStepIndex]; var action = AfterActions[state.NextAfterStepIndex];
var enumerator = InvokeAfter(action, Test, unityContext); var enumerator = InvokeAfter(action, Test, unityContext);
ActivePcHelper.SetEnumeratorPC(enumerator, state.NextAfterStepPc); ActivePcHelper.SetEnumeratorPC(enumerator, state.NextAfterStepPc);
using (var logScope = new LogScope()) using (var logScope = new LogScope())
{ {
while (true) while (true)
{ {
try try
{ {
if (!enumerator.MoveNext()) if (!enumerator.MoveNext())
{ {
break; break;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
context.CurrentResult.RecordPrefixedException(m_AfterErrorPrefix, ex); context.CurrentResult.RecordPrefixedException(m_AfterErrorPrefix, ex);
state.StoreTestResult(context.CurrentResult); state.StoreTestResult(context.CurrentResult);
break; break;
} }
state.NextAfterStepPc = ActivePcHelper.GetEnumeratorPC(enumerator); state.NextAfterStepPc = ActivePcHelper.GetEnumeratorPC(enumerator);
state.StoreTestResult(context.CurrentResult); state.StoreTestResult(context.CurrentResult);
if (m_SkipYieldAfterActions) if (m_SkipYieldAfterActions)
{ {
break; break;
} }
else else
{ {
yield return enumerator.Current; yield return enumerator.Current;
} }
} }
if (logScope.AnyFailingLogs()) if (logScope.AnyFailingLogs())
{ {
state.TestHasRun = true; state.TestHasRun = true;
context.CurrentResult.RecordPrefixedError(m_AfterErrorPrefix, new UnhandledLogMessageException(logScope.FailingLogs.First()).Message); context.CurrentResult.RecordPrefixedError(m_AfterErrorPrefix, new UnhandledLogMessageException(logScope.FailingLogs.First()).Message);
state.StoreTestResult(context.CurrentResult); state.StoreTestResult(context.CurrentResult);
} }
} }
state.NextAfterStepIndex++; state.NextAfterStepIndex++;
state.NextAfterStepPc = 0; state.NextAfterStepPc = 0;
} }
state.Reset(); state.Reset();
} }
public override TestResult Execute(ITestExecutionContext context) public override TestResult Execute(ITestExecutionContext context)
{ {
throw new NotImplementedException("Use ExecuteEnumerable"); throw new NotImplementedException("Use ExecuteEnumerable");
} }
private static TestCommandPcHelper pcHelper; private static TestCommandPcHelper pcHelper;
internal static TestCommandPcHelper ActivePcHelper internal static TestCommandPcHelper ActivePcHelper
{ {
get get
{ {
if (pcHelper == null) if (pcHelper == null)
{ {
pcHelper = new TestCommandPcHelper(); pcHelper = new TestCommandPcHelper();
} }
return pcHelper; return pcHelper;
} }
set set
{ {
pcHelper = value; pcHelper = value;
} }
} }
} }
} }
fileFormatVersion: 2 fileFormatVersion: 2
guid: cbbca1d8a0434be4bbc7f165523763ac guid: cbbca1d8a0434be4bbc7f165523763ac
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: 0
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment