Coded UI tests: Visual Studio Crashed while moving code from UIMap.Designer.cs to UIMap.cs from Coded UI Test Editor

Few days ago I encountered an error. When I try to move a recorded function from UIMap.designer.cs to UIMap.cs, visual studio got crashed.

I was unable to find why it stopped working correctly. After searching on forums etc I still get no clue.

Then I begin to inspect my code files and loaded a previous version of my solution and compared it to my current version. After few hours I was able to find the root cause.

The code written in the UIMAP.cs file should be in a specific order. The code should start like this.


{

    using Microsoft.VisualStudio.TestTools.UITesting.WinControls;

    using System;

    using System.Collections.Generic;

    using System.Drawing;

    using System.Windows.Input;

    using System.CodeDom.Compiler;

    using System.Text.RegularExpressions;

    using Microsoft.VisualStudio.TestTools.UITest.Extension;

    using Microsoft.VisualStudio.TestTools.UITesting;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;

    using Mouse = Microsoft.VisualStudio.TestTools.UITesting.Mouse;

    using MouseButtons = System.Windows.Forms.MouseButtons;

   

    public partial class UIMap


and my file was like that….


    using Microsoft.VisualStudio.TestTools.UITesting.WinControls;

    using System;

    using System.Collections.Generic;

    using System.Drawing;

    using System.Windows.Input;

    using System.CodeDom.Compiler;

    using System.Text.RegularExpressions;

    using Microsoft.VisualStudio.TestTools.UITest.Extension;

    using Microsoft.VisualStudio.TestTools.UITesting;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;

    using Mouse = Microsoft.VisualStudio.TestTools.UITesting.Mouse;

    using MouseButtons = System.Windows.Forms.MouseButtons;

    

namespace Saad.Maps.DMap

{

    public partial class UIMap

    {



Yeah, can you note the difference.

The using clause should come under namespace clause. If it is not the case , then coded ui test editor will not be able to move code in that UIMAP.cs file. If you correct the code sequence in the UIMAP.cs file and write using clause under namespace clause then you will be able to move code successfully.

I hope it will help somebody and this post should help Microsoft to remove that bug too.

4 thoughts on “Coded UI tests: Visual Studio Crashed while moving code from UIMap.Designer.cs to UIMap.cs from Coded UI Test Editor”

Leave a Reply

Your email address will not be published. Required fields are marked *