Пример #1
0
        private void TestPassed(TestPassedResult testResult)
        {
            var result = JsonConvert.DeserializeObject<Models.TestResult>(testResult.Output);
            var testResultViewModel = new TestResultViewModel
            {
                Status = result.Status,
                Name = result.TestName,
                Description = result.TestDescription,
                CollectionDescription = result.CollectionDescription,
                Url = result.Url,
                ScreenshotPath = result.ScreenshotPath,
                ResultOutput = result.TraceResult,
                Browser = result.DriverType.Description(),
            };

            var collectionName = result.CollectionName;

            AddResult(collectionName, testResultViewModel);
        }
Пример #2
0
        private void TestFailed(TestFailedResult testResult)
        {
            if (string.IsNullOrEmpty(testResult.Output))
            {
                var errorResultViewModel = new TestResultViewModel
                {
                    Status = ResultStatus.Failed,
                    Name = "Error",
                    Description = "An unknown error occured executing the test.",
                    CollectionDescription = "Error",
                    ResultOutput = testResult.ExceptionMessage,
                    StackTrace = testResult.ExceptionStackTrace,
                    Browser = DriverType.Unknown.ToString(),
                };

                AddResult("Test Execution Failure", errorResultViewModel);
                return;
            }

            var result = JsonConvert.DeserializeObject<Models.TestResult>(testResult.Output);
            var testResultViewModel = new TestResultViewModel
            {
                Status = result.Status,
                Name = result.TestName,
                Description = result.TestDescription,
                CollectionDescription = result.CollectionDescription,
                Url = result.Url,
                ScreenshotPath = result.ScreenshotPath,
                ResultOutput = testResult.ExceptionMessage + Environment.NewLine + result.TraceResult,
                StackTrace = testResult.ExceptionStackTrace,
                Browser = result.DriverType.Description(),
            };

            var collectionName = result.CollectionName;

            AddResult(collectionName, testResultViewModel);
        }
Пример #3
0
        private void AddResult(string collectionName, TestResultViewModel testResultViewModel)
        {
            switch (testResultViewModel.Status)
            {
                case ResultStatus.Failed:
                    _viewModel.FailedTests++;
                    break;

                case ResultStatus.Passed:
                    _viewModel.PassedTests++;
                    break;

                case ResultStatus.Skipped:
                    _viewModel.SkippedTests++;
                    break;
            }

            var collection = _viewModel.TestResults.FirstOrDefault(c => c.Name == collectionName);

            if (collection != null)
            {
                var container = collection.TestContainers.FirstOrDefault(c => c.Name == testResultViewModel.Name);

                if (container != null)
                {
                    var sourceCollection = container.TestResults.SourceCollection as ObservableCollection<TestResultViewModel>;
                    if (sourceCollection != null)
                        sourceCollection.Add(testResultViewModel);
                }
                else
                {
                    collection.TestContainers.Add(new TestResultContainerViewModel
                    {
                        Name = testResultViewModel.Name,
                        TestResults = GetTestView(testResultViewModel),
                        Description = testResultViewModel.Description
                    });
                }
            }
            else
            {
                // Test Collection didn't exist so add it.
                _viewModel.TestResults.Add(new TestResultCollectionViewModel
                {
                    Name = collectionName,
                    Description = testResultViewModel.CollectionDescription,
                    TestContainers = new ObservableCollection<TestResultContainerViewModel>
                            {
                                new TestResultContainerViewModel
                                    {
                                        Name = testResultViewModel.Name,
                                        Description = testResultViewModel.Description,
                                        TestResults = GetTestView(testResultViewModel),
                                    }
                            }
                });
            }
        }
Пример #4
0
        private ICollectionView GetTestView(TestResultViewModel testResult)
        {
            var testResults = new ObservableCollection<TestResultViewModel>
                {
                    testResult
                };

            var testResultsView = CollectionViewSource.GetDefaultView(testResults);
            testResultsView.Filter = TestResultsFilter;

            _testResultsViews.Add(testResultsView);

            return testResultsView;
        }
Пример #5
0
        public void DoExceptionThrown(TestAssembly testAssembly, Exception exception)
        {
            var testResultViewModel = new TestResultViewModel
            {
                Status = ResultStatus.Failed,
                Name = "Test Runner Error",
                StackTrace = exception.StackTrace,
                ResultOutput = exception.Message,
                Browser = "Unknown",
            };

            AddResult("Test Failure", testResultViewModel);
        }