Step 1: Install the Adapter
In the link you provided, a VSIX project is created to install the adapter. In the VSIX project there is an option (in the VSIX tab) to deploy the adapter automatically to the VS Experimental hive on build.
If you are using vstest.console.exe
you do no have to do this.
Step 2: Run the tests using the Adapter
Easiest way to do this and attach the debugger immediately is via 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 are running tests through VS:
devenv.exe /rootsuffix Exp
If you are running tests through vstest.console.exe
and you did not install the adapter on your main VS:
vstest.console.exe dummy.project.with.tests.dll /TestAdapterPath:"TestAdapterBuildDirectory"
If you are running 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 be run from
Use the Debug > Attach to Process option in Visual Studio.
In VS2013 most processes will hang around between test runs, so you can run the test once to start the processes, then attach to them before running the tests again. In VS2015 these processes don't tend to hang around long at all so you have to either attach to them very fast, or add a large sleep to your test executor to give you extra time to attach in.
If you've attached to the right process, and your test adapters were compiled with symbols, you should have no problem adding a breakpoint wherever you need in your adapter code.
The processes you need to attach to are as follows
VS2013
devenv.exe
- The VS instance. This is where any Test Container Discoverers you have created will be run.
vstest.discoveryengine.exe
- The discovery process. This is where any Test Discoverers will run, after being sent the test containers.
vstest.executionengine.exe
- The execution process. This is where any Test Executors will be run, after being sent the test cases. Therefore this is what you need to attach to if you want to see a test running.
VS2015
Some of these processes still exist, but you also need to attach to a number of processes, all called TE.ProcessHost.Managed.exe
. If you're not sure of which of these processes to attach to, attach to them all. Some will be for discovery and some will be for execution, though the execution processes will disappear very fast.
vstest.console.exe
This does not use the Test Discoverer or the Test Container Discoverer. If you are attached to the actual console program you should be able to inspect the running tests by adding breakpoints to the Test Executor. If this is not working I suspect the Adapter is not being run at all and you should look more closely at the /TestAdapterPath
and /UseVsixExtensions
options.