public void SendEvents(IList <CiEvent> list) { var eventList = new CiEventsList(); eventList.Events.AddRange(list); eventList.Server = new CiServerInfo { Url = _connectionDetails.TfsLocation, InstanceId = _connectionDetails.InstanceId, SendingTime = OctaneUtils.ConvertToOctaneTime(DateTime.UtcNow), InstanceIdFrom = OctaneUtils.ConvertToOctaneTime(DateTime.UtcNow) }; var baseUri = $"{INTERNAL_API}{_connectionDetails.SharedSpace}{ANALYTICS_CI_EVENTS}"; var body = JsonHelper.SerializeObject(eventList); var res = _restConnector.ExecutePut(baseUri, null, body); ValidateExpectedStatusCode(res, HttpStatusCode.OK); }
public static OctaneTestResult ConvertToOctaneTestResult(string serverId, string projectCiId, string buildCiId, IList <TfsTestResult> testResults, string runWebAccessUrl) { if (testResults.Count <= 0) { return(null); } //Serialization prepare var octaneTestResult = new OctaneTestResult(); var build = testResults[0].Build; var project = testResults[0].Project; octaneTestResult.Build = OctaneTestResultBuild.Create(serverId, buildCiId, projectCiId); /*octaneTestResult.TestFields = new List<OctaneTestResultTestField>(new[] { * OctaneTestResultTestField.Create(OctaneTestResultTestField.TEST_LEVEL_TYPE, "UnitTest") * });*/ octaneTestResult.TestRuns = new List <OctaneTestResultTestRun>(); foreach (var testResult in testResults) { var run = new OctaneTestResultTestRun(); if (testResult.AutomatedTestType.Equals("JUnit")) { var testNameParts = testResult.AutomatedTestStorage.Split('.'); run.Name = testResult.AutomatedTestName; run.Class = testNameParts[testNameParts.Length - 1]; run.Package = String.Join(".", new ArraySegment <String>(testNameParts, 0, testNameParts.Length - 1)); } else // UnitTest { var testNameParts = testResult.AutomatedTestName.Split('.'); run.Name = testNameParts[testNameParts.Length - 1]; run.Class = testNameParts[testNameParts.Length - 2]; run.Package = String.Join(".", new ArraySegment <String>(testNameParts, 0, testNameParts.Length - 2)); run.Module = Path.GetFileNameWithoutExtension(testResult.AutomatedTestStorage); } run.Duration = (long)testResult.DurationInMs; run.Status = testResult.Outcome; if (run.Status.Equals("NotExecuted")) { run.Status = "Skipped"; } if (run.Status.Equals("Failed")) { if (testResult.FailureType == "None" || String.IsNullOrEmpty(testResult.FailureType)) { testResult.FailureType = FindExceptionName(testResult); } run.Error = OctaneTestResultError.Create(testResult.FailureType, testResult.ErrorMessage, testResult.StackTrace); } run.Started = OctaneUtils.ConvertToOctaneTime(testResult.StartedDate); if (!string.IsNullOrEmpty(runWebAccessUrl)) { //Run WebAccessUrl http://berkovir:8080/tfs/DefaultCollection/Test2/_TestManagement/Runs#runId=8&_a=runCharts //Run Result WebAccessUrl http://berkovir:8080/tfs/DefaultCollection/Test2/_TestManagement/Runs#runId=8&_a=resultSummary&resultId=100000 run.ExternalReportUrl = runWebAccessUrl.Replace("_a=runCharts", ($"_a=resultSummary&resultId={testResult.Id}")); } octaneTestResult.TestRuns.Add(run); } return(octaneTestResult); }