상속: ITestFrameworkReporter
        private void DoTestBeginOfErrorMessage(bool inVisualStudio, string beginOfErrorMessage)
        {
            var errorMessage = "My error message";
            var result = new TestResult(TestDataCreator.ToTestCase("MyTestCase"))
            {
                Outcome = TestOutcome.Failed,
                ErrorMessage = errorMessage,
                ComputerName = "My Computer"
            };

            var reporter = new VsTestFrameworkReporter(MockFrameworkHandle.Object, inVisualStudio);
            reporter.ReportTestResults(result.Yield());

            MockFrameworkHandle.Verify(h => h.RecordResult(
                It.Is<VsTestResult>(tr => tr.ErrorMessage.Equals(beginOfErrorMessage + errorMessage))),
                Times.Exactly(1));
        }
        public void ReportTestResults_FromVsTestConsole_StacktraceEndsWithoutNewline()
        {
            var errorStacktrace = "My stack trace";
            var result = new TestResult(TestDataCreator.ToTestCase("MyTestCase"))
            {
                Outcome = TestOutcome.Failed,
                ErrorStackTrace = errorStacktrace + Environment.NewLine,
                ComputerName = "My Computer"
            };

            var reporter = new VsTestFrameworkReporter(MockFrameworkHandle.Object, false);
            reporter.ReportTestResults(result.Yield());

            MockFrameworkHandle.Verify(h => h.RecordResult(
                It.Is<VsTestResult>(tr => tr.ErrorStackTrace.Equals(errorStacktrace))),
                Times.Exactly(1));
        }
예제 #3
0
        private void DoTestBeginOfErrorMessage(bool inVisualStudio, string beginOfErrorMessage)
        {
            var errorMessage = "My error message";
            var result       = new TestResult(TestDataCreator.ToTestCase("MyTestCase"))
            {
                Outcome      = TestOutcome.Failed,
                ErrorMessage = errorMessage,
                ComputerName = "My Computer"
            };

            var reporter = new VsTestFrameworkReporter(MockFrameworkHandle.Object, inVisualStudio, MockLogger.Object);

            reporter.ReportTestResults(result.Yield());

            MockFrameworkHandle.Verify(h => h.RecordResult(
                                           It.Is <VsTestResult>(tr => tr.ErrorMessage.Equals(beginOfErrorMessage + errorMessage))),
                                       Times.Exactly(1));
        }
예제 #4
0
        public void ReportTestResults_FromVsTestConsole_StacktraceEndsWithoutNewline()
        {
            var errorStacktrace = "My stack trace";
            var result          = new TestResult(TestDataCreator.ToTestCase("MyTestCase"))
            {
                Outcome         = TestOutcome.Failed,
                ErrorStackTrace = errorStacktrace + Environment.NewLine,
                ComputerName    = "My Computer"
            };

            var reporter = new VsTestFrameworkReporter(MockFrameworkHandle.Object, false, MockLogger.Object);

            reporter.ReportTestResults(result.Yield());

            MockFrameworkHandle.Verify(h => h.RecordResult(
                                           It.Is <VsTestResult>(tr => tr.ErrorStackTrace.Equals(errorStacktrace))),
                                       Times.Exactly(1));
        }
        public void DiscoverTests(IEnumerable<string> executables, IDiscoveryContext discoveryContext,
            IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
        {
            if (_testEnvironment == null || _testEnvironment.Options.GetType() == typeof(SettingsWrapper)) // check whether we have a mock
            {
                _testEnvironment = TestExecutor.CreateTestEnvironment(discoveryContext.RunSettings, logger);
                _discoverer = new GoogleTestDiscoverer(_testEnvironment);
            }

            try
            {
                VsTestFrameworkReporter reporter = new VsTestFrameworkReporter(discoverySink);
                _discoverer.DiscoverTests(executables, reporter);
            }
            catch (Exception e)
            {
                _testEnvironment.LogError("Exception while discovering tests: " + e);
            }

        }
예제 #6
0
        private void DoRunTests(
            IEnumerable<TestCase> allTestCasesInExecutables, ICollection<TestCase> testCasesToRun,
            IRunContext runContext, IFrameworkHandle frameworkHandle, Stopwatch stopwatch)
        {
            bool isRunningInsideVisualStudio = !string.IsNullOrEmpty(runContext.SolutionDirectory);
            var reporter = new VsTestFrameworkReporter(frameworkHandle, isRunningInsideVisualStudio);
            var launcher = new DebuggedProcessLauncher(frameworkHandle);
            _executor = new GoogleTestExecutor(_testEnvironment);
            _executor.RunTests(allTestCasesInExecutables, testCasesToRun, reporter, launcher,
                runContext.IsBeingDebugged, runContext.SolutionDirectory);
            reporter.AllTestsFinished();

            stopwatch.Stop();
            _testEnvironment.LogInfo($"Google Test execution completed, overall duration: {stopwatch.Elapsed}.");
        }