Exemplo n.º 1
0
 public void OnFinish(TestCaseExecutionResult result, ILogger logger)
 {
     if (result.Exception != null)
     {
         var aggregateException = result.Exception as AggregateException;
         var messages           = aggregateException == null ? new[] { result.Exception.Message } : aggregateException.InnerExceptions.Select(_ => _.Message);
         result.Description.Root.Add(new XElement("ErrorMessage", messages.ToMultiLine()));
     }
 }
Exemplo n.º 2
0
        private async Task ExecuteTestCaseAsync(TestCase testCase)
        {
            var correlationId = Correlation.GetTickBasedId();

            using var scope = _logger.BeginScope(correlationId);

            _logger.LogDebug("Starting processing test case [{0}]", testCase.Id);
            var isMuted = testCase.Contains(".muted");

            if (isMuted)
            {
                _logger.LogDebug("Test is muted, not executing.");
            }

            var testResult = new TestCaseExecutionResult(testCase, isMuted);

            _results.Add(testResult);

            using var testCaseContext = CreateContext(testCase, correlationId, Options);
            var descriptionWriter = new XDocumentDescriptionWriter(testCaseContext.Logger);

            try
            {
                _customTestSession?.OnBegin(testCaseContext);
                await testCaseContext.ExecuteActionsAsync(_pipelineActionFactory, testCase.Actions, testCaseContext.Options.GetDeferExceptions(), _logger);
            }
            catch (Exception ex)
            {
                testCaseContext.Logger.LogError(ex, "an error occured");
                testResult.MarkAsFailed(ex);
            }

            try
            {
                testResult.Description = testCaseContext.DescriptionWriter.GetContent();
                _customTestSession?.OnFinish(testResult, testCaseContext.Logger);
            }
            catch (Exception ex)
            {
                testCaseContext.Logger.LogError(ex, "an error occured");
            }

            _logger.LogDebug("Finished processing test case [{0}]", testCase.Id);
        }
Exemplo n.º 3
0
 public void OnFinish(TestCaseExecutionResult result, ILogger logger)
 {
     logger.LogInformation("OnFinish {0}", result.TestCase.Id);
 }