A game about forced loneliness, made by TACStudios
1using System; 2using System.Collections; 3using NUnit.Framework.Interfaces; 4using NUnit.Framework.Internal; 5 6namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Events 7{ 8 internal class UpdateTestProgressTask : TestTaskBase 9 { 10 private TestProgress m_TestProgress; 11 12 public UpdateTestProgressTask() 13 { 14 RerunAfterResume = true; 15 } 16 17 public override IEnumerator Execute(TestJobData testJobData) 18 { 19 if (testJobData.testProgress == null) 20 { 21 throw new RequiredTestRunDataMissingException(nameof(testJobData.testProgress)); 22 } 23 24 if (testJobData.TestStartedEvent == null) 25 { 26 throw new RequiredTestRunDataMissingException(nameof(testJobData.TestStartedEvent)); 27 } 28 29 if (testJobData.TestFinishedEvent == null) 30 { 31 throw new RequiredTestRunDataMissingException(nameof(testJobData.TestFinishedEvent)); 32 } 33 34 m_TestProgress = testJobData.testProgress; 35 testJobData.TestStartedEvent.AddListener(TestStarted); 36 testJobData.TestFinishedEvent.AddListener(TestFinished); 37 38 yield break; 39 } 40 41 private void TestStarted(ITest test) 42 { 43 if (test.IsSuite || !(test is TestMethod)) 44 { 45 return; 46 } 47 48 m_TestProgress.CurrentTest = test.Name; 49 } 50 51 private void TestFinished(ITestResult testResult) 52 { 53 if (testResult.Test.IsSuite) 54 { 55 return; 56 } 57 var name = testResult.Test.FullName; 58 m_TestProgress.RemainingTests.Remove(name); 59 m_TestProgress.CompletedTests.Add(name); 60 } 61 } 62}