Exemple #1
0
        public void CoreIterationCleanup()
        {
            var exceptionStackTrace       = _thrownException?.Value?.ToString();
            var stackTrace                = new StackTrace();
            var benchmarkMethodMemberInfo = stackTrace.GetFrame(1).GetMethod() as MethodInfo;
            var benchmarkClassType        = benchmarkMethodMemberInfo?.DeclaringType;

            try
            {
                _currentBenchmarkExecutionProvider.PreTestCleanup(TestOutcome.Passed, benchmarkMethodMemberInfo?.Name, benchmarkMethodMemberInfo, benchmarkClassType, _categories, _authors, _descriptions, string.Empty, exceptionStackTrace, _thrownException?.Value);
                IterationCleanup();
                _currentBenchmarkExecutionProvider.PostTestCleanup(TestOutcome.Passed, benchmarkMethodMemberInfo?.Name, benchmarkMethodMemberInfo, benchmarkClassType, _categories, _authors, _descriptions, string.Empty, exceptionStackTrace, _thrownException?.Value);
            }
            catch (Exception ex)
            {
                _currentBenchmarkExecutionProvider.TestCleanupFailed(ex, benchmarkMethodMemberInfo?.Name, benchmarkMethodMemberInfo, benchmarkClassType, _categories, _authors, _descriptions);
                throw;
            }
        }
        public void CoreTestCleanup(string testName)
        {
            string consoleOutput = _stringWriter.ToString();

            _stringWriter.Close();
            string stackTrace           = ThrownException?.Value?.ToString();
            var    testClassType        = TestClassType;
            var    testMethodMemberInfo = GetCurrentExecutionMethodInfo(testName);

            Container = ServicesCollection.Current.FindCollection(testClassType.FullName);
            _currentTestExecutionProvider = new TestWorkflowPluginProvider();
            InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider);
            try
            {
                _currentTestExecutionProvider.PreTestCleanup(TestOutcome.Passed, testName, testMethodMemberInfo, testClassType, _categories, _authors, _descriptions, consoleOutput, stackTrace, ThrownException?.Value);
                TestCleanup();
                _currentTestExecutionProvider.PostTestCleanup(TestOutcome.Passed, testName, testMethodMemberInfo, testClassType, _categories, _authors, _descriptions, consoleOutput, stackTrace, ThrownException?.Value);
            }
            catch (Exception ex)
            {
                _currentTestExecutionProvider.TestCleanupFailed(ex, testName, testMethodMemberInfo, testClassType, _categories, _authors, _descriptions);
                throw;
            }
        }
        public void CoreTestCleanup()
        {
            var testClassType = GetCurrentExecutionTestClassType();

            Container = ServicesCollection.Current.FindCollection(testClassType.FullName);
            var testMethodMemberInfo = GetCurrentExecutionMethodInfo();
            var categories           = GetAllTestCategories();
            var authors      = GetAllAuthors();
            var descriptions = GetAllDescriptions();

            try
            {
                _currentTestExecutionProvider = new TestWorkflowPluginProvider();
                InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider);
                _currentTestExecutionProvider.PreTestCleanup((TestOutcome)TestContext.Result.Outcome.Status, TestContext.Test.Name, testMethodMemberInfo, testClassType, categories, authors, descriptions, TestContext.Result.Message, TestContext.Result.StackTrace, ThrownException?.Value);
                TestCleanup();
                _currentTestExecutionProvider.PostTestCleanup((TestOutcome)TestContext.Result.Outcome.Status, TestContext.Test.FullName, testMethodMemberInfo, testClassType, categories, authors, descriptions, TestContext.Result.Message, TestContext.Result.StackTrace, ThrownException?.Value);
            }
            catch (Exception ex)
            {
                _currentTestExecutionProvider.TestCleanupFailed(ex, TestContext.Test.Name, testMethodMemberInfo, testClassType, categories, authors, descriptions);
                throw;
            }
        }