public void OneTimeArrangeAct() { try { var testClassType = GetCurrentExecutionTestClassType(); Container = ServicesCollection.Current.CreateChildServicesCollection(testClassType.FullName); Container.RegisterInstance(Container); _currentTestExecutionProvider = new TestWorkflowPluginProvider(); Initialize(); InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider); _currentTestExecutionProvider.PreTestsArrange(testClassType); TestsArrange(); _currentTestExecutionProvider.PostTestsArrange(testClassType); _currentTestExecutionProvider.PreTestsAct(testClassType); TestsAct(); _currentTestExecutionProvider.PostTestsAct(testClassType); } catch (Exception ex) { _currentTestExecutionProvider.TestsArrangeFailed(ex); throw ex; } }
public void CoreTestInit(string testName) { if (ThrownException?.Value != null) { ThrownException.Value = null; } _stringWriter = new StringWriter(); Console.SetOut(_stringWriter); var testClassType = TestClassType; var testMethodMemberInfo = GetCurrentExecutionMethodInfo(testName); Container = ServicesCollection.Current.FindCollection(testClassType.FullName); _currentTestExecutionProvider = new TestWorkflowPluginProvider(); InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider); var categories = _categories; var authors = _authors; var descriptions = _descriptions; try { _currentTestExecutionProvider.PreTestInit(testName, testMethodMemberInfo, testClassType, categories, authors, descriptions); TestInit(); _currentTestExecutionProvider.PostTestInit(testName, testMethodMemberInfo, testClassType, categories, authors, descriptions); } catch (Exception ex) { Debug.WriteLine(ex); _currentTestExecutionProvider.TestInitFailed(ex, testName, testMethodMemberInfo, testClassType, categories, authors, descriptions); throw; } }
public void CoreTestInit() { if (ThrownException?.Value != null) { ThrownException.Value = null; } var testClassType = GetCurrentExecutionTestClassType(); Container = ServicesCollection.Current.FindCollection(testClassType.FullName); var testMethodMemberInfo = GetCurrentExecutionMethodInfo(); var categories = GetAllTestCategories(); var authors = GetAllAuthors(); var descriptions = GetAllDescriptions(); _currentTestExecutionProvider = new TestWorkflowPluginProvider(); InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider); try { _currentTestExecutionProvider.PreTestInit(TestContext.Test.Name, testMethodMemberInfo, testClassType, categories, authors, descriptions); TestInit(); _currentTestExecutionProvider.PostTestInit(TestContext.Test.Name, testMethodMemberInfo, testClassType, categories, authors, descriptions); } catch (Exception ex) { _currentTestExecutionProvider.TestInitFailed(ex, TestContext.Test.Name, testMethodMemberInfo, testClassType, categories, authors, descriptions); throw; } }
private void ExecuteActArrangePhases() { try { var testClassType = GetCurrentExecutionTestClassType(); if (!TypeForAlreadyExecutedClassInits.Contains(TestContext.FullyQualifiedTestClassName)) { Container = ServicesCollection.Current.CreateChildServicesCollection(testClassType.FullName); Container.RegisterInstance(Container); _currentTestExecutionProvider = new TestWorkflowPluginProvider(); InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider); TypeForAlreadyExecutedClassInits.Add(TestContext.FullyQualifiedTestClassName); _currentTestExecutionProvider.PreTestsArrange(testClassType); Initialize(); TestsArrange(); _currentTestExecutionProvider.PostTestsArrange(testClassType); _currentTestExecutionProvider.PreTestsAct(testClassType); TestsAct(); _currentTestExecutionProvider.PostTestsAct(testClassType); } } catch (Exception ex) { _currentTestExecutionProvider.TestsArrangeFailed(ex); } }
private void InitializeTestExecutionBehaviorObservers(TestWorkflowPluginProvider testExecutionProvider) { var observers = ServicesCollection.Current.ResolveAll <TestWorkflowPlugin>(); foreach (var observer in observers) { observer.Subscribe(testExecutionProvider); } }
static BaseSpecFlowHooks() { TestExecutionProvider = new TestWorkflowPluginProvider(); AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) => { if (eventArgs.Exception.Source != "System.Private.CoreLib") { if (ThrownException == null) { ThrownException = new ThreadLocal <Exception>(() => eventArgs.Exception); } else { ThrownException.Value = eventArgs.Exception; } } }; }
protected BaseBenchmark() { _currentBenchmarkExecutionProvider = new TestWorkflowPluginProvider(); InitializeBenchmarksExecutionBehaviorObservers(_currentBenchmarkExecutionProvider); AppDomain.CurrentDomain.FirstChanceException += (sender, eventArgs) => { if (eventArgs.Exception.Source != "System.Private.CoreLib") { if (_thrownException == null) { _thrownException = new ThreadLocal <Exception>(() => eventArgs.Exception); } else { _thrownException.Value = eventArgs.Exception; } } }; }
public void CoreClassCleanup() { var testClassType = GetCurrentExecutionTestClassType(); Container = ServicesCollection.Current.FindCollection(testClassType.FullName); _currentTestExecutionProvider = new TestWorkflowPluginProvider(); InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider); try { _currentTestExecutionProvider.PreClassCleanup(testClassType); TestsCleanup(); _currentTestExecutionProvider.PostClassCleanup(testClassType); } catch (Exception ex) { _currentTestExecutionProvider.TestsCleanupFailed(ex); 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; } }