Visual Studio 2013 custom test adapter: how to debug?

I am writing a custom Visual Studio Test Adapter and was wondering: how can I debug it? Now I am doing the following steps:

  • Adding multiple logger.SendMessage () log lines to my adapter code.
  • Adapter building
  • Copying the dll from step 2 above to the test extension folder (Common7 \ IDE \ CommonExtensions \ Microsoft \ TestWindow \ Extensions)
  • Run some tests from the console: vstest.console.exe dummy.project.with.tests.dll
  • View Log Output

Is there a way to debug my test adapter in VS2013 when running a test?

Note: my research found a comment in this post that says use Debugger.Launch () - but I don’t know how to activate this in order to achieve what I want.

+7
c # vs-unit-testing-framework visual-studio-extensions
source share
2 answers

Step 1: install the adapter

In the link for installing the adapter you provided, the VSIX project is created. The VSIX project has an option (on the VSIX tab) for automatically deploying the adapter in VS Experimental hive on build.

If you are using vstest.console.exe , you do not need to do this.

Step 2: Run the tests using the adapter

The easiest way to do this and immediately apply a debugger is the Debug tab in your project settings. Set this to start an external program, and the debugger will be attached to the program whenever you run it in debug mode.

If you use tests through VS:

 devenv.exe /rootsuffix Exp 

If you run tests through vstest.console.exe , and you do not install the adapter on your main VS:

 vstest.console.exe dummy.project.with.tests.dll /TestAdapterPath:"TestAdapterBuildDirectory" 

If you run tests through vstest.console.exe , and you did , install the adapter on your main VS:

 vstest.console.exe dummy.project.with.tests.dll /UseVsixExtentions:true 

Step 3. Attach the debugger to all the processes your adapter will work with

Use the Debug> Attach to Process option in Visual Studio.

In VS2013, most processes will hang between test runs, so you can run the test once to start the processes and then attach to them before running the tests again. In VS2015, these processes have no tendency to hang out for a long time, so you need to either attach them very quickly or add a big dream to your test performer to give you extra time to join.

If you connected to the correct process and your test adapters were compiled with characters, you should have no problem adding a breakpoint where you need to in the adapter code.

The processes you need to connect to are as follows

VS2013

  • devenv.exe - instance of VS. This will launch all the test container containers you create.
  • vstest.discoveryengine.exe - The discovery process. This is where all the testing discoverers will be launched after sending the test containers.
  • vstest.executionengine.exe - Execution process. Any test executors will be launched here after submitting test cases. Therefore, this is what you need to connect to if you want to see how the test passes.

VS2015

Some of these processes still exist, but you also need to attach to several processes, all called TE.ProcessHost.Managed.exe . If you don’t know which of these processes to join, join them all. Some of them will be detected, and some will be executed, although the execution processes will disappear very quickly.

vstest.console.exe

It does not use Test Discoverer or Discoverer to test the container. If you are connected to a specific console program, you can verify the tests performed by adding breakpoints to the test executor. If this does not work, I suspect that the adapter does not start at all, and you should take a closer look at the /TestAdapterPath and /UseVsixExtensions .

+5
source share

There is not much experience in this. As for step 3., you can also think about installing (and uninstalling) the VSIX test adapter package from the command line with:

 REM install vsixinstaller /q "C:\Path\To\Your\Adapter\bin\Debug\YourAdapter.vsix" REM uninstall vsixinstaller /q /a /u:YourVsixManifestId 
0
source share

All Articles