Example #1
0
        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 PluginProvider();
            InitializeTestExecutionBehaviorObservers(_currentTestExecutionProvider);
            var categories   = _categories;
            var authors      = _authors;
            var descriptions = _descriptions;

            try
            {
                _currentTestExecutionProvider.PreTestInit(testName, testMethodMemberInfo, testClassType, new List <object>(), categories, authors, descriptions);
                TestInit();
                _currentTestExecutionProvider.PostTestInit(testName, testMethodMemberInfo, testClassType, new List <object>(), categories, authors, descriptions);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                _currentTestExecutionProvider.TestInitFailed(ex, testName, testMethodMemberInfo, testClassType, new List <object>(), categories, authors, descriptions);
                throw;
            }
        }
Example #2
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;
            }
        }
Example #3
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;
            }
        }
Example #4
0
        public void CoreIterationSetup()
        {
            if (_thrownException?.Value != null)
            {
                _thrownException.Value = null;
            }

            var stackTrace = new StackTrace();
            var benchmarkMethodMemberInfo = stackTrace.GetFrame(1).GetMethod() as MethodInfo;
            var benchmarkClassType        = benchmarkMethodMemberInfo?.DeclaringType;
            var categories   = _categories;
            var authors      = _authors;
            var descriptions = _descriptions;

            try
            {
                _currentBenchmarkExecutionProvider.PreTestInit(benchmarkMethodMemberInfo?.Name, benchmarkMethodMemberInfo, benchmarkClassType, new List <object>(), categories, authors, descriptions);
                IterationInitialize();
                _currentBenchmarkExecutionProvider.PostTestInit(benchmarkMethodMemberInfo?.Name, benchmarkMethodMemberInfo, benchmarkClassType, new List <object>(), categories, authors, descriptions);
            }
            catch (Exception ex)
            {
                _currentBenchmarkExecutionProvider.TestInitFailed(ex, benchmarkMethodMemberInfo?.Name, benchmarkMethodMemberInfo, benchmarkClassType, new List <object>(), categories, authors, descriptions);
                throw;
            }
        }