private void DoRunTests(ICollection <TestCase> testCasesToRun, IRunContext runContext, IFrameworkHandle frameworkHandle) { if (testCasesToRun.Count == 0) { return; } bool isRunningInsideVisualStudio = !string.IsNullOrEmpty(runContext.SolutionDirectory); var reporter = new VsTestFrameworkReporter(frameworkHandle, isRunningInsideVisualStudio, _logger); var launcher = new DebuggedProcessLauncher(frameworkHandle); ProcessExecutor processExecutor = null; if (_settings.UseNewTestExecutionFramework) { IDebuggerAttacher debuggerAttacher = null; if (runContext.IsBeingDebugged) { debuggerAttacher = new MessageBasedDebuggerAttacher(_settings.DebuggingNamedPipeId, _logger); } processExecutor = new ProcessExecutor(debuggerAttacher, _logger); } lock (_lock) { if (_canceled) { return; } _executor = new GoogleTestExecutor(_logger, _settings); } _executor.RunTests(testCasesToRun, reporter, launcher, runContext.IsBeingDebugged, runContext.SolutionDirectory, processExecutor); reporter.AllTestsFinished(); }
private void DoTest(bool expectedResult) { string pipeId = Guid.NewGuid().ToString(); int debuggeeProcessId = 2017; // ReSharper disable once UnusedVariable var host = new DebuggerAttacherServiceHost(pipeId, MockDebuggerAttacher.Object, MockLogger.Object); try { host.Open(); var client = new MessageBasedDebuggerAttacher(pipeId, Timeout, MockLogger.Object); client.AttachDebugger(debuggeeProcessId, DebuggerEngine.Native).Should().Be(expectedResult); MockDebuggerAttacher.Verify(a => a.AttachDebugger(It.Is <int>(processId => processId == debuggeeProcessId), It.IsAny <DebuggerEngine>()), Times.Once); host.Close(); } catch (CommunicationException) { host.Abort(); throw; } }
private void DoTest(bool expectedOutcome, string expectedErrorMessagePart) { string pipeId = Guid.NewGuid().ToString(); int debuggeeProcessId = 2017; // ReSharper disable once UnusedVariable using (var service = new DebuggerAttacherService(pipeId, MockDebuggerAttacher.Object, MockLogger.Object)) { var client = MessageBasedDebuggerAttacher.CreateAndStartPipeClient( pipeId, (connection, msg) => { _messages.Add(msg); _resetEvent.Set(); }, MockLogger.Object); client.Should().NotBeNull(); client.PushMessage(new AttachDebuggerMessage { ProcessId = debuggeeProcessId }); _resetEvent.Wait(WaitingTime).Should().BeTrue(); _messages.Count.Should().Be(1); var message = _messages.Single(); message.ProcessId.Should().Be(debuggeeProcessId); message.DebuggerAttachedSuccessfully.Should().Be(expectedOutcome); if (string.IsNullOrEmpty(expectedErrorMessagePart)) { message.ErrorMessage.Should().Be(expectedErrorMessagePart); } else { message.ErrorMessage.Should().Contain(expectedErrorMessagePart); } } }
public void AttachDebugger_NoPipeAvailable_ErrorOutputGenerated() { var client = new MessageBasedDebuggerAttacher(Guid.NewGuid().ToString(), Timeout, MockLogger.Object); client.AttachDebugger(2017, DebuggerEngine.Native).Should().BeFalse(); MockLogger.Verify(l => l.LogError(It.Is <string>(s => s.Contains("EndpointNotFoundException"))), Times.Once); }
public void AttachDebugger_NoPipeAvailable_ErrorOutputGenerated() { var client = new MessageBasedDebuggerAttacher(Guid.NewGuid().ToString(), Timeout, MockLogger.Object); client.AttachDebugger(2017).Should().BeFalse(); MockLogger.Verify(l => l.LogError(It.Is <string>(s => s.Contains("Could not connect to NamedPipe"))), Times.Once); }
private void DoTest(bool expectedResult) { string pipeId = Guid.NewGuid().ToString(); int debuggeeProcessId = 2017; // ReSharper disable once UnusedVariable using (var service = new DebuggerAttacherService(pipeId, MockDebuggerAttacher.Object, MockLogger.Object)) { var client = new MessageBasedDebuggerAttacher(pipeId, Timeout, MockLogger.Object); client.AttachDebugger(debuggeeProcessId).Should().Be(expectedResult); MockDebuggerAttacher.Verify(a => a.AttachDebugger(It.Is <int>(processId => processId == debuggeeProcessId)), Times.Once); } }
private NamedPipeServer <AttachDebuggerMessage> CreateAndStartPipeServer() { string pipeName = MessageBasedDebuggerAttacher.GetPipeName(_debuggingNampedPipeId); var server = new NamedPipeServer <AttachDebuggerMessage>(pipeName); server.Error += exception => _logger.LogError($"Error on Named Pipe server:{Environment.NewLine}{exception}"); server.ClientMessage += OnAttachDebuggerMessageReceived; if (!server.Start()) { _logger.LogError($"Server side of named pipe could not be started, pipe name: {MessageBasedDebuggerAttacher.GetPipeName(_debuggingNampedPipeId)}"); return(null); } return(server); }