locked
SDK Package: How to create a unit/integration test and be able to load my package toolwindow inside my isolated shell RRS feed

  • Question

  • For:

    -C#

    -Visual Studio 2008 SDK SP1:

    -on Window XP

    - Issue on Developer machine

     

    Problem:

    I create a package to run in my isolated shell at the same time I also generated Unit Tests and Integrated Unit Test with the package. Now, I am trying to load my package in my own isolated shell,  I have looked at the following posting "Isolated shell integration testing" in order to be able to launch my own shell from my unit test:

    http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/91a6a948-dbaa-4c95-8d58-a073e4a0f2ba

    My shell loads but the before even my test code starts to run on for example the following generic integration test method:

     

     [TestMethod]



    [HostType("VS IDE")]



    public void PackageLoadTest()



    {



    UIThreadInvoker.Invoke((ThreadInvoker)delegate()



    {







    //Get the Shell Service



    IVsShell shellService = VsIdeTestHostContext.ServiceProvider.GetService(typeof(SVsShell)) as IVsShell;



    Assert.IsNotNull(shellService);







    //Validate package load



    IVsPackage package;



    Guid packageGuid = new Guid(ISaGRAF.Workbench.Dictionary.GuidList.guidMyEditorPkgString);



    Assert.IsTrue(0 == shellService.LoadPackage(ref packageGuid, out package));



    Assert.IsNotNull(package, "Package failed to load");







    });



    }

     

    I get a warning window telling me: There is no source code available for the following location, i press on OK and i get a null reference exception message for "Microsoft.VSSDK.TestHostAdapter"

    Here is the CallStack:

       at Microsoft.VSSDK.Tools.VsIdeHostAdapters.VsIdeHostAdapter.InitHostSide(VisualStudioHive registryHive, String hiveFlags) in f:\dd\vssdk\VSIntegration\Tools\src\IDEHostAdapter\HostAdapter\AgentSide\VsIdeHostAdapter.cs:line 256
       at Microsoft.VSSDK.Tools.VsIdeHostAdapters.VsIdeHostAdapter.CheckRestartVs(VisualStudioHive registryHive, ITestElement test) in f:\dd\vssdk\VSIntegration\Tools\src\IDEHostAdapter\HostAdapter\AgentSide\VsIdeHostAdapter.cs:line 485
       at Microsoft.VSSDK.Tools.VsIdeHostAdapters.VsIdeHostAdapter.Microsoft.VisualStudio.TestTools.Execution.IBaseAdapter.Run(ITestElement testElement, ITestContext testContext) in f:\dd\vssdk\VSIntegration\Tools\src\IDEHostAdapter\HostAdapter\AgentSide\VsIdeHostAdapter.cs:line 124
       at Microsoft.VisualStudio.TestTools.Agent.AgentExecution.CallAdapterRunMethod(Object obj)

     

    Now it seems that I need to specify the HostAdapter and so i investigated on the net and found the Visual Studio 2008 SDK sample "Microsoft.VSSDK.TestHostAdapter". But this sample refers to solution "VsIdeTestHost.sln" which does not even exists in the sample folder. Plus to tell you the thruth, all this seems so complicated with interfaces needed to implement and an Agent Side and a Host Side....I'm not sure if i'm looking in the right direction?

    Q1 - Isn't there an easier way to get this to work and start testing UI packaes/addins in an isolated shell in a much simpler way. some type of out of the box solution etc...

    Q2 - I would also like to know if there was any sort of recorder that could simulated UI actions and have that code be trasposed into the integration test (macro recorder maybe???).

    Q3 - Aside from the answers to the questions above, is there a sort of library i can easily use to get started in this direction, even if you could point me to a starting point of a small demo or documentation would be great ,where i can open solutions, capture clicks and textbox results and other UI related features i.e. do thisngs programmaticaly just liek a normal user would.

     

    Thank you

     

    Monday, November 1, 2010 10:02 PM

Answers

  • My apologies for the very slow response. The core question related to running package integration tests using your isolated shell, instead of the main VS IDE wasn't obvious. Some feedback from the folks that worked on the VS SDK helped immensly. Hopefully we'll get this documented.

    To get your integration tests to run under your isolated shell stub, you need to ensure that the DTE for the isolated shell is property registered, so that the host adapter can find and display the registry hive for your particular shell stub.

    The details are tucked away in the .reg file (in the "Shell Customization" folder) of your shell stub project. Once you have the registry keys properly installed (note, you'll need to replace the $RootFolder$ token with the actual path to your .exe), open your .testsettings file, select "VS IDE" for your host type, then set the "Visual Studio Registry Hive", to your shell's hive.

    This will ensure your integration tests run using the isolated shell instead of devenv.exe.

    I've played with the new coded UI feature a little, but I haven't actually tried it with the Visual Studio IDE. You could try that, but it's not a feature I'm familiar with, and you may run into problems with some of the native WIn32 windows that we still display in the IDE.

    Unfortunately, I don't know of any additional libraries apart from the pre-generated one we create with the integration and unit test projects.

    Sincerely


    Ed Dore
    Thursday, November 11, 2010 11:02 PM