Exemple #1
0
        public void CoreTestInit()
        {
            var testMethodMemberInfo = GetCurrentExecutionMethodInfo();
            var testClassType        = GetCurrentExecutionTestClassType();

            ExecuteActArrangePhases();

            Container = ServicesCollection.Current.FindCollection(testClassType.FullName);
            _currentTestExecutionProvider = new PluginProvider();
            InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider);

            var categories   = GetAllTestCategories(testMethodMemberInfo);
            var authors      = GetAllAuthors(testMethodMemberInfo);
            var descriptions = GetAllDescriptions(testMethodMemberInfo);

            try
            {
                Initialize();
                _currentTestExecutionProvider.PreTestInit(TestContext.TestName, testMethodMemberInfo, testClassType, new List <object>(), categories, authors, descriptions);
                TestInit();
                _currentTestExecutionProvider.PostTestInit(TestContext.TestName, testMethodMemberInfo, testClassType, new List <object>(), categories, authors, descriptions);
            }
            catch (Exception ex)
            {
                _currentTestExecutionProvider.TestInitFailed(ex, TestContext.TestName, testMethodMemberInfo, testClassType, new List <object>(), categories, authors, descriptions);
                throw;
            }
        }
Exemple #2
0
        public void OneTimeArrangeAct()
        {
            try
            {
                var testClassType = GetCurrentExecutionTestClassType();

                Container = ServicesCollection.Current.CreateChildServicesCollection(testClassType.FullName);
                Container.RegisterInstance(Container);
                _currentTestExecutionProvider = new PluginProvider();
                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;
            }
        }
Exemple #3
0
 private void ExecuteActArrangePhases()
 {
     try
     {
         var testClassType = GetCurrentExecutionTestClassType();
         if (!TypeForAlreadyExecutedClassInits.Contains(TestContext.FullyQualifiedTestClassName))
         {
             Container = ServicesCollection.Current.CreateChildServicesCollection(testClassType.FullName);
             Container.RegisterInstance(Container);
             _currentTestExecutionProvider = new PluginProvider();
             InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider);
             TypeForAlreadyExecutedClassInits.Add(TestContext.FullyQualifiedTestClassName);
             _currentTestExecutionProvider.PreTestsArrange(testClassType, new List <object>());
             Initialize();
             TestsArrange();
             _currentTestExecutionProvider.PostTestsArrange(testClassType);
             _currentTestExecutionProvider.PreTestsAct(testClassType, new List <object>());
             TestsAct();
             _currentTestExecutionProvider.PostTestsAct(testClassType, new List <object>());
         }
     }
     catch (Exception ex)
     {
         _currentTestExecutionProvider.TestsArrangeFailed(ex);
     }
 }
Exemple #4
0
        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 PluginProvider();
            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;
            }
        }
 public NUnitBaseTest()
 {
     Container = ServicesCollection.Current;
     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;
             }
         }
     };
 }
Exemple #6
0
        public void CoreClassCleanup()
        {
            var testClassType = GetCurrentExecutionTestClassType();

            Container = ServicesCollection.Current.FindCollection(testClassType.FullName);
            _currentTestExecutionProvider = new PluginProvider();
            InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider);

            try
            {
                _currentTestExecutionProvider.PreClassCleanup(testClassType);
                TestsCleanup();
                _currentTestExecutionProvider.PostClassCleanup(testClassType);
            }
            catch (Exception ex)
            {
                _currentTestExecutionProvider.TestsCleanupFailed(ex);
                throw;
            }
        }
        public void ClassCleanup()
        {
            try
            {
                var testClassType = GetCurrentExecutionTestClassType();

                Container = ServicesCollection.Current.CreateChildServicesCollection(testClassType.FullName);
                Container.RegisterInstance(Container);
                _currentTestExecutionProvider = new TestWorkflowPluginProvider();
                InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider);

                _currentTestExecutionProvider.PreClassCleanup(testClassType);
                TestsCleanup();
                _currentTestExecutionProvider.PostClassCleanup(testClassType);
            }
            catch (Exception ex)
            {
                _currentTestExecutionProvider.TestsCleanupFailed(ex);
                throw;
            }
        }
Exemple #8
0
        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;
            }
        }
Exemple #9
0
        public NUnitBaseTest()
        {
            _container = ServicesCollection.Current;
            if (!_isConfigurationExecuted.Value)
            {
                Configure();
                _isConfigurationExecuted.Value = true;
            }

            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;
                    }
                }
            };
        }