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, new List <object>(), _categories, _authors, _descriptions, string.Empty, exceptionStackTrace, _thrownException?.Value); IterationCleanup(); _currentBenchmarkExecutionProvider.PostTestCleanup(TestOutcome.Passed, benchmarkMethodMemberInfo?.Name, benchmarkMethodMemberInfo, benchmarkClassType, new List <object>(), _categories, _authors, _descriptions, string.Empty, exceptionStackTrace, _thrownException?.Value); } catch (Exception ex) { _currentBenchmarkExecutionProvider.TestCleanupFailed(ex, benchmarkMethodMemberInfo?.Name, benchmarkMethodMemberInfo, benchmarkClassType, new List <object>(), _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 PluginProvider(); InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider); try { _currentTestExecutionProvider.PreTestCleanup(TestOutcome.Passed, testName, testMethodMemberInfo, testClassType, new List <object>(), _categories, _authors, _descriptions, consoleOutput, stackTrace, ThrownException?.Value); TestCleanup(); _currentTestExecutionProvider.PostTestCleanup(TestOutcome.Passed, testName, testMethodMemberInfo, testClassType, new List <object>(), _categories, _authors, _descriptions, consoleOutput, stackTrace, ThrownException?.Value); } catch (Exception ex) { _currentTestExecutionProvider.TestCleanupFailed(ex, testName, testMethodMemberInfo, testClassType, new List <object>(), _categories, _authors, _descriptions); throw; } }
public void CoreTestCleanup() { var testMethodMemberInfo = GetCurrentExecutionMethodInfo(); var testClassType = GetCurrentExecutionTestClassType(); var categories = GetAllTestCategories(testMethodMemberInfo); var authors = GetAllAuthors(testMethodMemberInfo); var descriptions = GetAllDescriptions(testMethodMemberInfo); Container = ServicesCollection.Current.FindCollection(testClassType.FullName); _currentTestExecutionProvider = new PluginProvider(); InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider); try { _currentTestExecutionProvider.PreTestCleanup((TestOutcome)TestContext.CurrentTestOutcome, TestContext.TestName, testMethodMemberInfo, testClassType, new List <object>(), categories, authors, descriptions, _thrownException?.Value?.Message, _thrownException?.Value?.StackTrace, _thrownException?.Value); TestCleanup(); _currentTestExecutionProvider.PostTestCleanup((TestOutcome)TestContext.CurrentTestOutcome, TestContext.TestName, testMethodMemberInfo, testClassType, new List <object>(), categories, authors, descriptions, _thrownException?.Value?.Message, _thrownException?.Value?.StackTrace, _thrownException?.Value); } catch (Exception ex) { _currentTestExecutionProvider.TestCleanupFailed(ex, TestContext.TestName, testMethodMemberInfo, testClassType, new List <object>(), categories, authors, descriptions); throw; } }