Exemplo n.º 1
0
        private void AddResult(string collectionName, TestResultViewModel testResultViewModel)
        {
            switch (testResultViewModel.Status)
            {
            case ResultStatus.Failed:
                FailedTests++;
                break;

            case ResultStatus.Passed:
                PassedTests++;
                break;

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

            var collection = 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),
                    });
                }
            }
            else
            {
                // Test Collection didn't exist so add it.
                TestResults.Add(new TestResultCollectionViewModel
                {
                    Name           = collectionName,
                    TestContainers = new ObservableCollection <TestResultContainerViewModel>
                    {
                        new TestResultContainerViewModel
                        {
                            Name        = testResultViewModel.Name,
                            TestResults = GetTestView(testResultViewModel),
                        }
                    }
                });
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        private void TestPassed(TestPassedResult testResult)
        {
            var result = JsonConvert.DeserializeObject <Models.TestResult>(testResult.Output);
            var testResultViewModel = new TestResultViewModel
            {
                Status       = result.Status,
                Name         = result.TestName,
                Url          = result.Url,
                ResultOutput = result.TraceResult,
                Browser      = result.DriverType.Description(),
            };

            var collectionName = result.CollectionName;

            AddResult(collectionName, testResultViewModel);
        }
Exemplo n.º 5
0
        private void TestFailed(TestFailedResult testResult)
        {
            var result = JsonConvert.DeserializeObject <Models.TestResult>(testResult.Output);
            var testResultViewModel = new TestResultViewModel
            {
                Status       = result.Status,
                Name         = result.TestName,
                Url          = result.Url,
                ResultOutput = testResult.ExceptionMessage + Environment.NewLine + result.TraceResult,
                StackTrace   = testResult.ExceptionStackTrace,
                Browser      = result.DriverType.Description(),
            };

            var collectionName = result.CollectionName;

            AddResult(collectionName, testResultViewModel);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
0
        private void AddResult(string collectionName, TestResultViewModel testResultViewModel)
        {
            switch (testResultViewModel.Status)
            {
                case ResultStatus.Failed:
                    FailedTests++;
                    break;

                case ResultStatus.Passed:
                    PassedTests++;
                    break;

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

            var collection = 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.
                TestResults.Add(new TestResultCollectionViewModel
                    {
                        Name = collectionName,
                        Description = testResultViewModel.CollectionDescription,
                        TestContainers = new ObservableCollection<TestResultContainerViewModel>
                            {
                                new TestResultContainerViewModel
                                    {
                                        Name = testResultViewModel.Name,
                                        Description = testResultViewModel.Description,
                                        TestResults = GetTestView(testResultViewModel),
                                    }
                            }
                    });
            }
        }
Exemplo n.º 10
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);
        }