How to create and install test adapter in Visual Studio

前端 未结 2 900
轻奢々
轻奢々 2021-01-01 06:52

I want\' to create a protractor test adapter for Visual Studio. I have found I can create it with implementing ITestExecutor and ITestDiscoverer.
I follow the Marcel De

2条回答
  •  醉酒成梦
    2021-01-01 07:31

    If you need to run the test adapter with vstest.console.exe but don't need visual studio integration you will need to do the following:

    • Create a project that is a class library
    • Very important: The assembly name must end with .TestAdapter or vstest.console.exe will not recognize your test adapter. You can change this setting in the properties of your project.
    • Import Microsoft.VisualStudio.TestPlatform.ObjectModel which for me was located at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll
    • You only need to implement ITestDiscoverer and ITestExecutor
    • If your test adapter is for .dll or .exe files the default test adapter will run first. I could not find a way to disable this.

    The above accepted answer and code was very useful for me when figuring out how to create a test adapter. Be aware that if you are creating a VSIX then the asset type UnitTestExtension is not available in the list but seems to work and can be added in the .vsixmanifest file manually.

    Additional useful links:

    • https://blogs.msdn.microsoft.com/aseemb/2012/03/03/how-to-make-your-extension-visible-to-the-test-explorer-in-visual-studio-11/
    • https://blogs.msdn.microsoft.com/visualstudioalm/2012/07/31/writing-a-visual-studio-2012-unit-test-adapter/
    • https://blog.dantup.com/2014/02/some-things-i-learned-while-building-my-visual-studio-test-adapter/

提交回复
热议问题