示例#1
0
        public static IEnumerable <ResolvableItemDescription> GetActionDescriptions(this TestCase testCase, ITestCaseProcessorFactory factory)
        {
            var processor = factory.GetProcessor(testCase);

            try
            {
                var pipelineProcessor = processor as IActionPipelineProcessor;
                if (pipelineProcessor != null)
                {
                    return(pipelineProcessor.ActionDecsriptions);
                }

                return(Enumerable.Empty <ResolvableItemDescription>());
            }
            finally
            {
                factory.Release(processor);
            }
        }
示例#2
0
        private void OnTestCase(TestCase testCase)
        {
            _logger.LogDebug("Starting processing test case [{0}]", testCase.Id);
            var isMuted = testCase.Contains(".muted");

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

            TestCaseResult testResult = new TestCaseResult(testCase, isMuted);

            _results.Add(testResult);

            var testCaseContext = _testCaseContextFactory.CreateContext(testCase, Options);

            try
            {
                var descriptionWriter = new XDocumentDescriptionWriter(testCaseContext.Logger);
                if (_customTestSessions != null)
                {
                    foreach (var session in _customTestSessions)
                    {
                        session.OnBegin(testCaseContext);
                    }
                }

                ITestCaseProcessor processor = null;
                try
                {
                    processor = _testCaseProcessorFactory.GetProcessor(testCase);
                    processor.Process(testCaseContext);
                }
                catch (Exception ex)
                {
                    testCaseContext.Logger.LogError(ex, "an error occured");
                    testResult.MarkAsFailed(ex);
                }
                finally
                {
                    if (processor != null)
                    {
                        _testCaseProcessorFactory.Release(processor);
                    }
                }

                try
                {
                    testResult.Description = testCaseContext.DescriptionWriter.GetContent();
                }
                catch (Exception ex)
                {
                    testCaseContext.Logger.LogError(ex, "an error occured while getting test case description");
                }

                if (_customTestSessions != null)
                {
                    foreach (var session in _customTestSessions)
                    {
                        session.OnFinish(testResult, testCaseContext.Logger);
                    }
                }
            }
            finally
            {
                _testCaseContextFactory.Release(testCaseContext);
            }

            _logger.LogDebug("Finished processing test case [{0}]", testCase.Id);
        }