private void MergeChildren(TestResult other, TestResult merged) { if (other.Results == null) return; foreach (TestResult otherChild in other.Results) { var mergedChild = merged.FindDescedant( d => { if (otherChild.Test.TestType == TestType.Assembly.ToString() && d.Test.TestType == TestType.Assembly.ToString()) return Path.GetFileName(d.FullName).Equals(Path.GetFileName(otherChild.FullName)); return d.FullName.Equals(otherChild.FullName); }); if (mergedChild == null) { AddResult(merged, otherChild); continue; } Merge(otherChild, mergedChild); } }
/// <summary> /// Adds for reprocessing if required. /// </summary> /// <param name="test">The test.</param> /// <param name="result">The result.</param> /// <param name="agent"> </param> public void AddForReprocessingIfRequired(TestUnitWithMetadata test, TestResult result, AgentMetadata agent) { var request = requests != null ? requests.GetBy(test.Test.Run) : null; Action registerReprocessing = () => { if (request != null) request.Statistics.RegisterReprocessing(); }; if (result == null) { test.AttachedData.NullReprocessingCount++; collection.Add(test); log.Info(string.Format("REPROCESSING (as null): '{0}' was added for reprocessing. [{1}]", test.FullName, test.Test.Run)); registerReprocessing(); return; } if (!test.Test.Info.IsSuite) { var childResult = result.FindDescedant(d => d.FullName.Equals(test.FullName)); if (childResult != null && ProcessResult(childResult, test.Test.Run, test) == ReprocessingVerdict.PerformReprocessing) { AddTestForReprocessing(test, agent); registerReprocessing(); } return; } foreach (var suiteResult in result.FindBottomLevelTestSuites()) { if (test.FullName.Equals(suiteResult.FullName)) { var reprocessingVerdict = ProcessResult(suiteResult, test.Test.Run, test); if (reprocessingVerdict == ReprocessingVerdict.MaximumCountWasReached) return; if (reprocessingVerdict == ReprocessingVerdict.PerformReprocessing) { AddTestForReprocessing(test, agent); registerReprocessing(); continue; } } var childrenForReprocessing = new List<Tuple<TestResult, TestUnitWithMetadata>>(); foreach (TestResult childResult in suiteResult.Results) { var childTest = test.Children.FirstOrDefault(ct => ct.FullName.Equals(childResult.FullName)); if (ProcessResult(childResult, test.Test.Run, childTest, () => { childTest = new TestUnitWithMetadata(test.Test.Run, childResult.Test, test.Test.AssemblyName); test.Children.Add(childTest); return childTest; })==ReprocessingVerdict.PerformReprocessing) childrenForReprocessing.Add(new Tuple<TestResult, TestUnitWithMetadata>(childResult, childTest)); } if (childrenForReprocessing.Count > 0 && childrenForReprocessing.Count == suiteResult.Results.Count) { AddTestForReprocessing(test, agent); registerReprocessing(); } else { foreach (var childForReprocessing in childrenForReprocessing) { AddTestForReprocessing(childForReprocessing.Item2, agent); registerReprocessing(); } } } }