Trackyon CUIT Helpers

Trackyon LLC CUIT Helpers The Coded UI Test (CUIT) Helpers from Trackyon LLC allows IIS Express or Visual Studio Development Server (Cassini Web server) to be started by your test.  This prevents Coded UI Test from beginning without a server running. Features: Start and Stop IIS Express Start and Stop Visual Studio Development Server (Cassini Web server) Usage: To start using the package verify the app.config file of your test project contains either the webDevPath and/or the iisExpressPath values added to your appSettings section. These values are used by the library to start the respective web server.  If you installed the package using nuget the keys were added for you with paths assuming you are running .NET 4.0 and on a 64 bit machine.  If you are not running .NET 40 or not on a 64 bit machine you will need to adjust the paths. <add key="webDevPath" value="C:\Program Files (x86)\Common Files\microsoft shared\DevServer\11.0\WebDev.WebServer40" /> <add key="iisExpressPath" value="C:\Program Files (x86)\IIS Express\iisexpress" /> Starting Visual Studio Development Server (Cassini Web server) You can use the static Start method of the WebDev class in the Trackyon.CUIT.Helpers namespace.  The Start method takes two parameters port and path. Port is the port you want the web server to use to host your application.  Path is the path to the project to load.  The WebDev class provides a helper method FindProjectFolder that given the TestContext and Project Name will determine the path for you at runtime so the path is not hard coded.  Hard coding the path would require all developers to map the project to the same location on their machines.  The example below would start the MyWebApp project of the currently loaded solution on port 8081. WebDev.Start(8081, WebDev.FindProjectFolder(TestContext, "MyWebApp")); Once the test run is complete simply call Close to stop the server.  Starting IIS Express The IISExpress class also provides a static Start method, however, this method only takes a single parameter sitename.  The site name must map to a site already configured in your applicationhost.config file.  The site would be configured in the applicationhost.config file if you have setup your project to use IIS Express from the Web section of the project properties.  This file can be located in one of the two following locations: %userprofile%\documents\iisexpress\config\applicationhost.config %userprofile%\my documents\iisexpress\config\applicationhost.config The example below would start the MyWebApp site in IIS Express. IISExpress.Start("MyWebApp"); Once the test run is complete simply call Close to stop the server. Known Issues The icons for the servers may stay in Notification Area after the server has been closed.  Simply hovering your mouse over the icons will make them disappear. The servers will close after the test is complete regardless if you call close or not. They are created as child processes of the test assembly and when the test are unloaded the process is terminated.

KB2870699 breaks Coded UI Test

Problem: All my Coded UI Test start failing because they can't find the controls.  Solution: Uninstall KB2870699 - MS13-069: Cumulative security update for Internet Explorer: September 10, 2013. Explanation: After my machine applied several windows updates all my Coded UI Test that were working before the updates all began to fail. The test were unable to perform actions because the controls were hidden.  Each test would fail with the following exception: Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToPerformActionOnHiddenControlException You can read more about the issue here: Further Information After I uninstalled the update and rebooted my machine all my test began to run again.

I can't access app.config from my web test plug in

Problem:  I want to read the connection strings from my app.config of my Web Test Project but it never loads.  Solution:  Use the Configuration Manager OpenMappedExeConfiguration call to load the app.config file.  Code:  // Map the new configuration file.ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();configFileMap.ExeConfigFilename =   System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + ".config"; // Get the mapped configuration filevar config = ConfigurationManager.OpenMappedExeConfiguration(   configFileMap, ConfigurationUserLevel.None); Explanation: The app.config of the test project is not loaded for web or load tests, because they are run in the same application domain as the test process (either vstesthost.exe or qtagent.exe), so they will load their config files instead. Therefore, we simply load the configuration file ourselves. Loading a configuration file is a two phased process.  First we build a ExcConfigurationFileMap object and set the name of our configuration file to be loaded. Then we open that file with a call to OpenMappedExeConfiguration method of the ConfigurationManager class. I am not a fan of hard coded values so we are going to get the name of the assembly using reflection and simply concatenate ".config" to the end of it.  Calling System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name will return the name of the assembly. After calling OpenMappedExeConfiguration you can use the returned object to access the connection strings or any other data from the app.config.

I can't connect to my load test repository.

Problem: When I try to Open and Manage Results from my load test I get an error: Solution: Make sure your controller is configured with the full name to the database server instead of . or .\sqlexpress.  Change to mySqlServer or mySqlServer\sqlExpress.

My web test data source is not loading all the columns from my csv file.

Problem: I have a data driven web test that calls other web test. The called web tests are also data bound to data loaded by the parent data source.  When I run my test I was getting the following error: Request failed: Context parameter 'FluidManagement.FluidManagement_json#csv.spacer2' not found in test context Solution: Expand the Data Sources node of your web test until you can select the desired table.  From the Properties window change the Select Columns from “Only select bound columns” to “Select all columns”. Explanation: The default behavior is to only select the columns that are bound the web test that defines the data source.  This is a reasonable assumption as long as the test does not call any other data bound web test.  If the test you call rely on columns that are not bound in the caller you must change the Select Columns setting.

I only see the last 10 steps of my Exploratory Testing in MTM when I create a test case.

Problem: I used the "Do Exploratory Testing" freature of Microsoft Test Manager (MTM) but only the last 10 steps show up when I create a test case. Solution: In the new test case window press the "Change steps" button above the test steps.  This will bring up a dialog box allowing you to select additional steps.   Explanation: The default number of steps to include in a test case is 10. That value is in the mtm.exe.config file: <!-- The number of actions selected by default when a bug or test case is created         while exploring the app or providing feedback. The number of actions displayed by default are         four times this number -->    <add key="DefaultNumberOfActions" value="10"/>  

More fun with CUIT

Problem: I have a CUIT that does not run as fast as I would like. Solution: Use the Coded UI Test Editor in Feature Pack 2 to adjust the actions recorded. Explanation: