コード例 #1
0
        private void ExecuteTestsWithTestRunner(
            IEnumerable <TestCase> tests,
            IRunContext runContext,
            ITestExecutionRecorder testExecutionRecorder,
            string source,
            IDictionary <string, object> sourceLevelParameters,
            UnitTestRunner testRunner)
        {
            foreach (var currentTest in tests)
            {
                if (this.cancellationToken != null && this.cancellationToken.Canceled)
                {
                    break;
                }

                var unitTestElement = currentTest.ToUnitTestElement(source);
                testExecutionRecorder.RecordStart(currentTest);

                var startTime = DateTimeOffset.Now;

                PlatformServiceProvider.Instance.AdapterTraceLogger.LogInfo("Executing test {0}", unitTestElement.TestMethod.Name);

                // Run single test passing test context properties to it.
                var tcmProperties         = TcmTestPropertiesProvider.GetTcmProperties(currentTest);
                var testContextProperties = this.GetTestContextProperties(tcmProperties, sourceLevelParameters);
                var unitTestResult        = testRunner.RunSingleTest(unitTestElement.TestMethod, testContextProperties);

                PlatformServiceProvider.Instance.AdapterTraceLogger.LogInfo("Executed test {0}", unitTestElement.TestMethod.Name);

                var endTime = DateTimeOffset.Now;

                this.SendTestResults(currentTest, unitTestResult, startTime, endTime, testExecutionRecorder);
            }
        }
コード例 #2
0
ファイル: TestExecutionManager.cs プロジェクト: tbolon/testfx
        private void ExecuteTestsWithTestRunner(
            IEnumerable <TestCase> tests,
            IRunContext runContext,
            ITestExecutionRecorder testExecutionRecorder,
            string source,
            IDictionary <string, object> sourceLevelParameters,
            UnitTestRunner testRunner)
        {
            var testExecutionRecorderWrapper = new TestExecutionRecorderWrapper(testExecutionRecorder);

            foreach (var currentTest in tests)
            {
                if (this.cancellationToken != null && this.cancellationToken.Canceled)
                {
                    break;
                }

                var unitTestElement = currentTest.ToUnitTestElement(source);

                // Fire a RecordStart here even though we also fire RecordStart inside TestMethodInfo
                // this is to ensure we fire start events for error cases. This is acceptable because
                // vstest ignores multiple start events.
                testExecutionRecorder.RecordStart(currentTest);

                var startTime = DateTimeOffset.Now;

                PlatformServiceProvider.Instance.AdapterTraceLogger.LogInfo(
                    "Executing test {0}",
                    unitTestElement.TestMethod.Name);

                // Run single test passing test context properties to it.
                var tcmProperties         = TcmTestPropertiesProvider.GetTcmProperties(currentTest);
                var testContextProperties = this.GetTestContextProperties(tcmProperties, sourceLevelParameters);
                var unitTestResult        = testRunner.RunSingleTest(unitTestElement.TestMethod, testExecutionRecorderWrapper, testContextProperties);

                PlatformServiceProvider.Instance.AdapterTraceLogger.LogInfo(
                    "Executed test {0}",
                    unitTestElement.TestMethod.Name);

                var endTime = DateTimeOffset.Now;

                this.SendTestResults(currentTest, unitTestResult, startTime, endTime, testExecutionRecorder);
            }
        }