1

Using the sample project from MSDN, I'm writing a custom unit test adapter. I'm able to debug it with the experimental instance in visual studio, set breakpoints, and see System.Diagnostics.Trace.WriteLine() output, and it all works beautifully for almost all of my methods. I can see evidence that it's working (as in the outputs of the test cases are what I expect if I fiddle with the error message, duration, etc).

However, for the methods in my test executor class (deriving from Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.ITestExecutor), I neither hit my breakpoints nor see any of my trace output. Is there a setting or something to make that work? I'm wondering if the test execution framework is doing some kind of optimization on this class that makes it harder to debug.

Thank you.

Jay Carlton
  • 1,118
  • 1
  • 11
  • 27
  • One workaround is to open a separate log file as a `System.IO.StreamWriter` and just write to it. I still don't get why I can't write to the Output window with `Trace.WriteLine()` though from this particular class. – Jay Carlton Jul 17 '14 at 19:20

1 Answers1

2

You have to attach the debugger to the process vstest.executionengine.x86.exe, which is a child spawned by devenv.exe. I'm assuming the same trick applies to vstest.discoveryengine.x86.exe for the test discovery code.

Bonus Question: Is there a way to set up the debugger to attach to those automatically when I debug my unit test adapter project?

Jay Carlton
  • 1,118
  • 1
  • 11
  • 27
  • You can [configure this per exe name](https://msdn.microsoft.com/en-us/library/a329t4ed(v=vs.100).aspx). You can also call [Debugger.Launch()](https://msdn.microsoft.com/de-de/library/system.diagnostics.debugger.launch(v=vs.110).aspx) in your ITestExecutor – m3tikn0b Jan 13 '16 at 15:50