Migrating Coded UI Test Projects on VS 2012

Aditya_msft

In Visual Studio 2012, Coded UI Test projects provide silent upgrade features where if you open a Coded UI Test project which was created in Visual Studio 2010 SP1, it will get repaired automatically to support both Visual Studio 2012 & Visual Studio 2010 SP1. Similarly if you create any new Coded UI Test project in Visual Studio 2012, you can also open the same project in Visual Studio 2010 SP1 after doing some tweaks without any issues.

How does it work

                When we open a Coded UI Test project in Visual Studio 2012, it puts all Visual Studio 2010 Coded UI Test references to conditional reference section, so that these references get enabled only when there is appropriate version of Visual Studio.

<Choose>

    <When Condition=”‘$(VisualStudioVersion)’ == ‘10.0’ And ‘$(IsCodedUITest)’ == ‘True'”>

      <ItemGroup>

        <Reference Include=”Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL”>

          <Private>False</Private>

        </Reference>

        <Reference Include=”Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL”>

          <Private>False</Private>

        </Reference>

        <Reference Include=”Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL”>

          <Private>False</Private>

        </Reference>

        <Reference Include=”Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL”>

          <Private>False</Private>

        </Reference>

      </ItemGroup>

    </When>

  </Choose>

Also adds a target file entry in the end of project file which provide details of Visual Studio 2012 reference details.

<Import Project=”$(VSToolsPath)TeamTestMicrosoft.TestTools.targets” Condition= “Exists(‘$(VSToolsPath)TeamTestMicrosoft.TestTools.targets’)” />

 Now if you open this project in Visual Studio 2010 SP1, only the first conditional block is picked for the referencing Coded UI Test assemblies. Since the target file is not present in the setup, import statement will not load Visual Studio 2012 references.

Similarly if the same project is opened in Visual Studio 2012, first conditional block is not picked thus no Visual Studio 2010 assemblies are picked, but presence of Target file provides 11.0 version assemblies.

So if you don’t have any other Visual Studio version specific reference you project is good to go in both Visual Studio 2012 & Visual Studio 2010 Sp1. All you have to do is to build the project and run the tests.

 

What to do with custom references

                Silent repair in Coded UI Test project will not touch any custom reference which was added by the user. In such cases, if the referenced assembly has any Visual Studio version dependency, then you have to fix the references by yourself.

                To resolve your issue you can always use Conditional referencing and use $(VisualStudioVersion) attribute to identify with which Visual Studio version your solution is opened.

 

Any in house assembly which is using Visual Studio references

If you have any in house assembly in your test framework and using these references, you have to modify that also to enable seamless experience in Coded UI Test. Both your local assemblies & test project have to be built every time the project is opened in Visual Studio

 

How to convert a Visual Studio 2012 Coded UI Test project to 2010 SP1

                If you have created any Coded UI Test project in Visual Studio 2012 and you want to work in Visual Studio 2010 Sp1, there are few things you have to take care

  1. Visual Studio 2010 doesn’t support .NET v4.5, so you have to change your Target framework to v4.0 to open the project in Visual Studio 2010 SP1.
  2. You should not use any new features which were not present in Visual Studio 2010 SP1. You can get details of such features from MSDN.

 

What to do with Visual Studio 2010 Feature Pack 2

                In Visual Studio 2012 RTM, support for SilverLight & Firefox browser is not there by default. However you can install plug in for Silverlight from Code Gallery. Also we are releasing playback support for Firefox and Chrome browser as part of our quarterly update for Visual Studio 2012 which is planned to release by end of 2012.

                Silent upgrade of Coded UI Test project will take care of putting old Visual Studio 2010 Feature Pack 2 references inside Conditional reference block,  but since there are no references available in Visual Studio 2012 for Silverlight extension, you have to add it by yourself.

 

What is my project is part of Team Build

                If your Coded UI Test project is part of Team build, to enable the project build on both client 2010 & 2012, also to build it in as part of team build, you have to open the project at least once in Visual Studio 2012, let it get repaired and check in the updated project. Also if you have using any custom references, you have to fix them manually.

 

Projects are not getting build in Build Agent 2012

                If you are trying to build a Coded UI Test project as part of team build where build agents are version 2012, you have to install either Visual Studio 2012 Ultimate or Visual Studio 2012 Premium.

 

Ordered tests are not picking Coded UI Test

                If you have both Visual Studio 2012 & Visual Studio 2010 Sp1 installed on the same machine, you may encounter issues with OrderedTest.  For example when trying to open an ordered test from Test Explorer in Visual Studio 2012 IDE, you get error message as unable to load Coded UI Test assemblies.

                This happens because the default program which is assigned for Ordered Test is still Visual Studio 2010 Sp1, so when you do a double click on any ordered test in Visual Studio 2012 Ide, it launches Visual Studio 2010 SP1,where it fails to refer 10.0 references. To resolve this issue, please associate Visual Studio 2012 as default program for opening ordered test.

                  

0 comments

Discussion is closed.

Feedback usabilla icon