public string GenerateTRXReport ( TestSummary testSummary ) { var runId = _guidService.NewGuid().ToString(); var testSettingsGuid = _guidService.NewGuid().ToString(); var testLists = new TestList[] { new TestList { Id = _guidService.NewGuid().ToString(), Name = TEST_LIST_NAME_RESULTS_NOT_IN_A_LIST }, new TestList { Id = _guidService.NewGuid().ToString(), Name = TEST_LIST_NAME_ALL_LOADED_TESTS } }; var testRun = new TestRun { Id = runId, Name = $"{ TEST_RUN_NAME} {testSummary.StartDateTime.ToString(@"yyyy-MM-dd HH:mm:ss")}", RunUser = TEST_RUN_USER, Times = new Times { Creation = testSummary.StartDateTime.ToString(@"yyyy-MM-ddTHH:mm:ss.FFFFFFF+00:00"), Finsh = testSummary.EndDateTime.ToString(@"yyyy-MM-ddTHH:mm:ss.FFFFFFF+00:00"), Queuing = testSummary.StartDateTime.ToString(@"yyyy-MM-ddTHH:mm:ss.FFFFFFF+00:00"), Start = testSummary.StartDateTime.ToString(@"yyyy-MM-ddTHH:mm:ss.FFFFFFF+00:00") }, TestSettings = new TestSettings { Deployment = new Deployment { RunDeploymentRoot = RUN_DEPLOYMENT_ROOT }, Name = DEPLOYMENT_NAME, Id = testSettingsGuid.ToString() }, Results = testSummary.TestResults.Select(testResult => new UnitTestResult { ComputerName = COMPUTER_NAME, Duration = testResult.Duration.ToString(), StartTime = testResult.StartTime.ToString(@"yyyy-MM-ddTHH:mm:ss.FFFFFFF+00:00"), EndTime = testResult.EndTime.ToString(@"yyyy-MM-ddTHH:mm:ss.FFFFFFF+00:00"), ExecutionId = testResult.ExecutionId.ToString(), Outcome = testResult.Pass ? "passed" : "failed", RelativeResultsDirectory = RELATIVE_RESULTS_DIRECTORY, TestId = testResult.TestId.ToString(), TestListId = testLists[0].Id, TestName = testResult.TestName, TestType = testResult.TestType.ToString(), }).ToArray(), TestDefinitions = testSummary.TestResults.Select(testResult => new UnitTest { Execution = new Execution { Id = testResult.ExecutionId.ToString() }, Id = testResult.TestId.ToString(), Name = testResult.TestName, Storage = UNIT_TEST_PATH, TestMethod = new TestMethod { AdapterTypeName = ADAPTER_TYPE_NAME, ClassName = testResult.ClassName, CodeBase = CODE_BASE, Name = testResult.TestName } }).ToArray(), TestEntries = testSummary.TestResults.Select(testResult => new TestEntry { ExecutionId = testResult.ExecutionId.ToString(), TestId = testResult.TestId.ToString(), TestListId = testLists[0].Id }).ToArray(), TestLists = testLists, ResultSummary = new ResultSummary { Outcome = RESULT_OUTCOME, Counters = new Counters { Total = testSummary.TestResults.Count(), Executed = testSummary.TestResults.Count(), Passed = testSummary.TestResults.Count(testresult => testresult.Pass), Failed = testSummary.TestResults.Count(testresult => !testresult.Pass) } } }; XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); XmlSerializer xmlSerializer = new XmlSerializer(testRun.GetType()); using Utf8StringWriter textWriter = new Utf8StringWriter(); xmlSerializer.Serialize(textWriter, testRun, ns); return(textWriter.ToString()); }