public async Task UpdateOfInProgressIsNotAllowed() { var originalRequest = new StartTestItemRequest { LaunchUuid = _fixture.LaunchUuid, Name = "UpdateAttributes", StartTime = DateTime.UtcNow }; var test = await Service.TestItem.StartAsync(originalRequest); var tempTest = await Service.TestItem.GetAsync(test.Uuid); var updateRequest = new UpdateTestItemRequest() { Status = Status.Passed }; Func <Task> act = async() => await Service.TestItem.UpdateAsync(tempTest.Id, updateRequest); var exp = await act.Should().ThrowExactlyAsync <ReportPortalException>(); exp.WithInnerExceptionExactly <HttpRequestException>().WithMessage("*Unable to update status*"); await Service.TestItem.FinishAsync(test.Uuid, new FinishTestItemRequest { EndTime = DateTime.UtcNow, Status = Status.Passed }); }
public async Task UpdateDescription() { var originalRequest = new StartTestItemRequest { LaunchUuid = _fixture.LaunchUuid, Name = "UpdateDescription", StartTime = DateTime.UtcNow }; var test = await Service.TestItem.StartAsync(originalRequest); var tempTest = await Service.TestItem.GetAsync(test.Uuid); var updateRequest = new UpdateTestItemRequest() { Description = "newDesc", }; var updateMessage = await Service.TestItem.UpdateAsync(tempTest.Id, updateRequest); updateMessage.Info.Should().Contain("successfully"); var updatedTest = await Service.TestItem.GetAsync(test.Uuid); updatedTest.Name.Should().Be(originalRequest.Name); updatedTest.Description.Should().Be(updateRequest.Description); await Service.TestItem.FinishAsync(test.Uuid, new FinishTestItemRequest { EndTime = DateTime.UtcNow, Status = Status.Passed }); }
public async Task UpdateStatus(Status status) { var originalRequest = new StartTestItemRequest { LaunchUuid = _fixture.LaunchUuid, Name = "UpdateAttributes", StartTime = DateTime.UtcNow }; var test = await Service.TestItem.StartAsync(originalRequest); await Service.TestItem.FinishAsync(test.Uuid, new FinishTestItemRequest { EndTime = DateTime.UtcNow, Status = Status.Passed }); var tempTest = await Service.TestItem.GetAsync(test.Uuid); var updateRequest = new UpdateTestItemRequest() { Status = status }; await Service.TestItem.UpdateAsync(tempTest.Id, updateRequest); var updatedTest = await Service.TestItem.GetAsync(test.Uuid); updatedTest.Name.Should().Be(originalRequest.Name); updatedTest.Description.Should().Be(originalRequest.Description); updatedTest.Status.Should().Be(status); }
/// <summary> /// Update specified test item. /// </summary> /// <param name="id">ID of test item to update.</param> /// <param name="model">Information about test item.</param> /// <returns>A message from service.</returns> public virtual async Task <Message> UpdateTestItemAsync(string id, UpdateTestItemRequest model) { var uri = BaseUri.Append($"{Project}/item/{id}/update"); var body = ModelSerializer.Serialize <UpdateTestItemRequest>(model); var response = await _httpClient.PutAsync(uri, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(false); response.VerifySuccessStatusCode(); return(ModelSerializer.Deserialize <Message>(await response.Content.ReadAsStringAsync().ConfigureAwait(false))); }
public void Update(UpdateTestItemRequest request) { if (FinishTask == null || !FinishTask.IsCompleted) { AdditionalTasks.Add(Task.Run(async() => { StartTask.Wait(); await _service.UpdateTestItemAsync(TestId, request); })); } }
public void TraceStep(StepInstance stepInstance, bool showAdditionalArguments) { if (CurrentScenario != null) { CurrentScenarioDescription += Environment.NewLine + stepInstance.Keyword + " " + stepInstance.Text; if (stepInstance.MultilineTextArgument != null) { CurrentScenarioDescription += Environment.NewLine + stepInstance.MultilineTextArgument; } var tableDescription = string.Empty; if (stepInstance.TableArgument != null) { tableDescription = string.Empty; foreach (var header in stepInstance.TableArgument.Header) { tableDescription += "| " + header + "\t"; } tableDescription += "|\n"; foreach (var row in stepInstance.TableArgument.Rows) { foreach (var value in row.Values) { tableDescription += "| " + value + "\t"; } tableDescription += "|\n"; } } if (!string.IsNullOrEmpty(tableDescription)) { CurrentScenarioDescription += Environment.NewLine + tableDescription; } var updateScenarioRequest = new UpdateTestItemRequest { Description = CurrentScenarioDescription }; CurrentScenario.Update(updateScenarioRequest); var stepInfoRequest = new AddLogItemRequest { Level = LogLevel.Info, //TODO log time should be greater than test time Time = DateTime.UtcNow.AddMilliseconds(1), Text = string.Format("{0}\r{1}", stepInstance.Keyword + " " + stepInstance.Text, tableDescription) }; CurrentScenario.Log(stepInfoRequest); } }
public void Update(UpdateTestItemRequest request) { if (FinishTask == null || !FinishTask.IsCompleted) { if (_additionalTasks == null) { _additionalTasks = new ConcurrentBag <Task>(); } _additionalTasks.Add(StartTask.ContinueWith(async(a) => { await _service.UpdateTestItemAsync(TestInfo.Id, request); }).Unwrap()); } }
public void TestFinished(TestResult result) { if (result.Message != null && _testId != null) { Bridge.Service.AddLogItem(new AddLogItemRequest { TestItemId = _testId, Time = DateTime.UtcNow, Level = LogLevel.Error, Text = result.Message + "\n" + result.StackTrace }); } var requestUpdateTest = new UpdateTestItemRequest { Description = result.Description, Tags = (from object tag in result.Test.Categories select tag.ToString()).ToList() }; Bridge.Service.UpdateTestItem(_testId, requestUpdateTest); var requestFinishTest = new FinishTestItemRequest { EndTime = DateTime.UtcNow, Status = _statusMap[result.ResultState] }; var eventArg = new TestItemFinishedEventArgs(Bridge.Service, requestFinishTest, result, null, _testId); if (BeforeTestFinished != null) { BeforeTestFinished(this, eventArg); } if (!eventArg.Canceled) { var message = Bridge.Service.FinishTestItem(_testId, requestFinishTest).Info; if (AfterTestFinished != null) { AfterTestFinished(this, new TestItemFinishedEventArgs(Bridge.Service, requestFinishTest, result, message, _testId)); } _testId = null; Bridge.Context.TestId = null; } }
public async Task UpdateAttributes() { var originalRequest = new StartTestItemRequest { LaunchUuid = _fixture.LaunchUuid, Name = "UpdateAttributes", StartTime = DateTime.UtcNow }; var test = await Service.TestItem.StartAsync(originalRequest); var tempTest = await Service.TestItem.GetAsync(test.Uuid); var updateRequest = new UpdateTestItemRequest() { Attributes = new List <ItemAttribute> { new ItemAttribute { Key = "k1", Value = "v1" } }, }; var updateMessage = await Service.TestItem.UpdateAsync(tempTest.Id, updateRequest); updateMessage.Info.Should().Contain("successfully"); var updatedTest = await Service.TestItem.GetAsync(test.Uuid); updatedTest.Name.Should().Be(originalRequest.Name); updatedTest.Attributes.Should().BeEquivalentTo(updateRequest.Attributes); await Service.TestItem.FinishAsync(test.Uuid, new FinishTestItemRequest { EndTime = DateTime.UtcNow, Status = Status.Passed }); }
public void TestFinished(TestResult result) { if (_testId != null) { foreach (var message in result.Messages) { foreach (var line in message.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) { var handled = false; try { var sharedMessage = Client.Converters.ModelSerializer.Deserialize <SharedLogMessage>(line); var logRequest = new AddLogItemRequest { Level = sharedMessage.Level, Time = sharedMessage.Time, TestItemId = sharedMessage.TestItemId, Text = sharedMessage.Text }; if (sharedMessage.Attach != null) { logRequest.Attach = new Attach { Name = sharedMessage.Attach.Name, MimeType = sharedMessage.Attach.MimeType, Data = sharedMessage.Attach.Data }; } _testId.Log(logRequest); handled = true; } catch (Exception) { } if (!handled) { _testId.Log(new AddLogItemRequest { Time = DateTime.UtcNow, Level = LogLevel.Info, Text = line }); } } } if (result.ErrorMessage != null) { _testId.Log(new AddLogItemRequest { Time = result.EndTime.UtcDateTime, Level = LogLevel.Error, Text = result.ErrorMessage + "\n" + result.ErrorStackTrace }); } if (result.Attachments != null) { foreach (var attachmentSet in result.Attachments) { foreach (var attachmentData in attachmentSet.Attachments) { var filePath = attachmentData.Uri.AbsolutePath; if (File.Exists(filePath)) { var fileExtension = Path.GetExtension(filePath); _testId.Log(new AddLogItemRequest { Level = LogLevel.Info, Text = Path.GetFileName(filePath), Time = result.EndTime.UtcDateTime, Attach = new Attach(Path.GetFileName(filePath), Shared.MimeTypes.MimeTypeMap.GetMimeType(fileExtension), File.ReadAllBytes(filePath)) }); } else { _testId.Log(new AddLogItemRequest { Level = LogLevel.Warning, Text = $"'{filePath}' file is not available.", Time = result.EndTime.UtcDateTime, }); } } } } var description = result.TestCase.Traits.FirstOrDefault(x => x.Name == "Description"); var requestUpdateTest = new UpdateTestItemRequest { Description = description != null ? description.Value : String.Empty, Tags = result.TestCase.Traits.Where(t => t.Name.ToLower() == "Category".ToLower()).Select(x => x.Value).ToList() }; _testId.Update(requestUpdateTest); var requestFinishTest = new FinishTestItemRequest { EndTime = result.EndTime.UtcDateTime, Status = _statusMap[result.Outcome] }; _testId.Finish(requestFinishTest); } }
public Task <MessageResponse> UpdateAsync(long id, UpdateTestItemRequest model) { throw new NotImplementedException(); }
public Task <MessageResponse> UpdateAsync(long id, UpdateTestItemRequest request) { return(PutAsJsonAsync <MessageResponse, UpdateTestItemRequest>( $"{ProjectName}/item/{id}/update", request)); }
private void FinishSuite(XmlDocument xmlDoc) { try { var id = xmlDoc.SelectSingleNode("/*/@id").Value; var result = xmlDoc.SelectSingleNode("/*/@result").Value; var parentId = xmlDoc.SelectSingleNode("/*/@parentId"); // at the end of execution nunit raises 2 the same events, we need only that which has 'parentId' xml tag if (parentId != null) { if (_suitesFlow.ContainsKey(id)) { var updateSuiteRequest = new UpdateTestItemRequest(); // adding categories to suite var categories = xmlDoc.SelectNodes("//properties/property[@name='Category']"); if (categories != null) { updateSuiteRequest.Tags = new List <string>(); foreach (XmlNode category in categories) { updateSuiteRequest.Tags.Add(category.Attributes["value"].Value); } } // adding description to suite var description = xmlDoc.SelectSingleNode("//properties/property[@name='Description']"); if (description != null) { updateSuiteRequest.Description = description.Attributes["value"].Value; } if (updateSuiteRequest.Description != null || updateSuiteRequest.Tags != null) { _suitesFlow[id].AdditionalTasks.Add(Task.Run(async() => { _suitesFlow[id].StartTask.Wait(); await Bridge.Service.UpdateTestItemAsync(_suitesFlow[id].TestId, updateSuiteRequest); })); } // finishing suite var finishSuiteRequest = new FinishTestItemRequest { EndTime = DateTime.UtcNow, Status = _statusMap[result] }; var eventArg = new TestItemFinishedEventArgs(Bridge.Service, finishSuiteRequest, _suitesFlow[id]); try { if (BeforeSuiteFinished != null) { BeforeSuiteFinished(this, eventArg); } } catch (Exception exp) { Console.WriteLine("Exception was thrown in 'BeforeSuiteFinished' subscriber." + Environment.NewLine + exp); } _suitesFlow[id].Finish(finishSuiteRequest); try { if (AfterSuiteFinished != null) { AfterSuiteFinished(this, new TestItemFinishedEventArgs(Bridge.Service, finishSuiteRequest, _suitesFlow[id])); } } catch (Exception exp) { Console.WriteLine("Exception was thrown in 'AfterSuiteFinished' subscriber." + Environment.NewLine + exp); } } } } catch (Exception exception) { Console.WriteLine("ReportPortal exception was thrown." + Environment.NewLine + exception); } }
public void FinishTest(XmlDocument xmlDoc) { try { var id = xmlDoc.SelectSingleNode("/*/@id").Value; var result = xmlDoc.SelectSingleNode("/*/@result").Value; var parentId = xmlDoc.SelectSingleNode("/*/@parentId"); if (_testFlowIds.ContainsKey(id)) { var updateTestRequest = new UpdateTestItemRequest(); // adding categories to test var categories = xmlDoc.SelectNodes("//properties/property[@name='Category']"); if (categories != null) { updateTestRequest.Tags = new List <string>(); foreach (XmlNode category in categories) { updateTestRequest.Tags.Add(category.Attributes["value"].Value); } } // adding description to test var description = xmlDoc.SelectSingleNode("//properties/property[@name='Description']"); if (description != null) { updateTestRequest.Description = description.Attributes["value"].Value; } if (updateTestRequest.Description != null || updateTestRequest.Tags != null) { _testFlowIds[id].Update(updateTestRequest); } // adding console output var outputNode = xmlDoc.SelectSingleNode("//output"); if (outputNode != null) { _testFlowIds[id].Log(new AddLogItemRequest { Level = LogLevel.Trace, Time = DateTime.UtcNow, Text = "Test Output: " + Environment.NewLine + outputNode.InnerText }); } // adding failure message var failureNode = xmlDoc.SelectSingleNode("//failure"); if (failureNode != null) { var failureMessage = failureNode.SelectSingleNode("./message").InnerText; var failureStacktrace = failureNode.SelectSingleNode("./stack-trace").InnerText; _testFlowIds[id].Log(new AddLogItemRequest { Level = LogLevel.Error, Time = DateTime.UtcNow, Text = failureMessage + Environment.NewLine + failureStacktrace }); } // finishing test var finishTestRequest = new FinishTestItemRequest { EndTime = DateTime.UtcNow, Status = _statusMap[result] }; var isRetry = xmlDoc.SelectSingleNode("//properties/property[@name='Retry']"); if (isRetry != null) { finishTestRequest.IsRetry = true; } var eventArg = new TestItemFinishedEventArgs(Bridge.Service, finishTestRequest, _testFlowIds[id]); try { if (BeforeTestFinished != null) { BeforeTestFinished(this, eventArg); } } catch (Exception exp) { Console.WriteLine("Exception was thrown in 'BeforeTestFinished' subscriber." + Environment.NewLine + exp); } _testFlowIds[id].Finish(finishTestRequest); try { if (AfterTestFinished != null) { AfterTestFinished(this, new TestItemFinishedEventArgs(Bridge.Service, finishTestRequest, _testFlowIds[id])); } } catch (Exception exp) { Console.WriteLine("Exception was thrown in 'AfterTestFinished' subscriber." + Environment.NewLine + exp); } } } catch (Exception exception) { Console.WriteLine("ReportPortal exception was thrown." + Environment.NewLine + exception); } }