locked
How to get the Selected Item on the Visual Studio Environment Test Windows? RRS feed

  • Question

  • Hi!

    I'm developing a VSIX extension for Visual Studio to keep track of useful Unit Test information. 

    To help the interaction with this extension, i've managed to add button on the Test Result and Test Explorer Context Menus. When the Click Event is fired, i cannot get the Selected Item in any of the Windows.

    I've tried to look into the windows on EnvDTE, but i can't downcast to it's original type.

    The code that i'm using is:

    var dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.12.0");
    if (dte2.ActiveWindow.Caption == "Test Explorer" || dte2.ActiveWindow.Caption == "Test Results") {
         // do stuff here
    }

    Is there any way to get the SelectedItem, or, in the worst case scenario, the Name of the Test in the Selected Item?

    Thank you!

    Monday, August 24, 2015 9:14 AM

Answers

  • I'm pretty certain IVsMonitorSelection won't work in this instance. The Test Explorer window does not appear to be offering up it's selection state to the IDE, as evidenced by the lack of support for the Properties Toolwindow.

    As far as I can tell, this particular Toolwindow does not offer up any extensibility points :-( .

    Sincerely,


    Ed Dore

    Tuesday, August 25, 2015 5:25 PM

All replies

  • Hi Duarte,

    I didn't find any good way to get the selected test item from the Test Exlorer, maybe you can try IVsMonitorSelection object. And you may try Unit Test Adapter instead of Test Explorer Extension. I see many kinds of Unit Test Adapter in VS Gallery, but I can't see any Test Explorer extensions.

    I hope these two blog posts give you some ideas:

    http://blogs.msdn.com/b/visualstudioalm/archive/2012/07/31/writing-a-visual-studio-2012-unit-test-adapter.aspx

    http://blogs.msdn.com/b/bhuvaneshwari/archive/2012/03/13/authoring-a-new-visual-studio-test-adapter.aspx


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, August 25, 2015 9:59 AM
  • I'm pretty certain IVsMonitorSelection won't work in this instance. The Test Explorer window does not appear to be offering up it's selection state to the IDE, as evidenced by the lack of support for the Properties Toolwindow.

    As far as I can tell, this particular Toolwindow does not offer up any extensibility points :-( .

    Sincerely,


    Ed Dore

    Tuesday, August 25, 2015 5:25 PM