locked
Open a custom tool window from TestAdapter RRS feed

  • Question

  • Hi,

    I've started writing a TestAdapter for VS2012 that creates some custom output.  I've written a tool window to display this output.  The TestAdapter is not a VS package, and I'd like to keep the test adapter and the package/tool window separate.

    Is there any way to tell VS to open the tool window from the test adapter?  I've found a reference (http://msdn.microsoft.com/en-us/library/bb164576(v=vs.110).aspx) that describes how to find and open a tool window, but it only seems to work from inside a VSPackage.

    Thanks,

    Nick

    Tuesday, November 6, 2012 7:48 PM

Answers

  • Hi Nick,

    Not familiar with Test Adapters, but it sounds like these run in-process to the VS IDE. So you could simply retrieve the EnvDTE.DTE interface for the currently running instance of VS, and then use DTE.ExecuteCommand, to execute the command responsible for showing your toolwindow.

    You might be able to use the Package.GetGlobalService to retrieve the DTE service, by taking a dependency on the Microsoft.VisualStudio.Shell.11.0.dll.

    Sincerely,


    Ed Dore

    Tuesday, November 6, 2012 11:49 PM
  • Hi Ed,

    This sounds like the right path so far.  Test adapters are new to VS2012 and let you run whatever kind of tests you want from VS like they're mstest tests (http://blogs.msdn.com/b/visualstudioalm/archive/2012/07/31/writing-a-visual-studio-2012-unit-test-adapter.aspx)

    Anyways, I've got the DTE reference in my test adapter, but now I'm not sure how to open a tool window.  I started trying to use MEF to open it up, but I haven't gotten that working.  I do need to pass some data to the tool window if that changes anything.  I could probably just use ItemOperations.OpenFile to send the data, but I'd rather use a tool window instead of a custom editor.

    Thanks,

    Nick

    • Marked as answer by Ego Jiang Tuesday, November 27, 2012 9:04 AM
    Wednesday, November 7, 2012 12:32 AM

All replies

  • Hi Nick,

    Not familiar with Test Adapters, but it sounds like these run in-process to the VS IDE. So you could simply retrieve the EnvDTE.DTE interface for the currently running instance of VS, and then use DTE.ExecuteCommand, to execute the command responsible for showing your toolwindow.

    You might be able to use the Package.GetGlobalService to retrieve the DTE service, by taking a dependency on the Microsoft.VisualStudio.Shell.11.0.dll.

    Sincerely,


    Ed Dore

    Tuesday, November 6, 2012 11:49 PM
  • Hi Ed,

    This sounds like the right path so far.  Test adapters are new to VS2012 and let you run whatever kind of tests you want from VS like they're mstest tests (http://blogs.msdn.com/b/visualstudioalm/archive/2012/07/31/writing-a-visual-studio-2012-unit-test-adapter.aspx)

    Anyways, I've got the DTE reference in my test adapter, but now I'm not sure how to open a tool window.  I started trying to use MEF to open it up, but I haven't gotten that working.  I do need to pass some data to the tool window if that changes anything.  I could probably just use ItemOperations.OpenFile to send the data, but I'd rather use a tool window instead of a custom editor.

    Thanks,

    Nick

    • Marked as answer by Ego Jiang Tuesday, November 27, 2012 9:04 AM
    Wednesday, November 7, 2012 12:32 AM