示例#1
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 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;
            }
        }
示例#2
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 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;
            }
        }
示例#3
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, categories, authors, descriptions);
                IterationInitialize();
                _currentBenchmarkExecutionProvider.PostTestInit(benchmarkMethodMemberInfo?.Name, benchmarkMethodMemberInfo, benchmarkClassType, categories, authors, descriptions);
            }
            catch (Exception ex)
            {
                _currentBenchmarkExecutionProvider.TestInitFailed(ex, benchmarkMethodMemberInfo?.Name, benchmarkMethodMemberInfo, benchmarkClassType, categories, authors, descriptions);
                throw;
            }
        }