by Donovan Brown
26. April 2013 20:40
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 file
var 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.
by Donovan Brown
7. December 2012 02:56
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.
by Donovan Brown
5. December 2012 20:06
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.
by Donovan Brown
1. December 2012 01:41
Problem:
I would like to feed data to an existing Coded UI test from a datasource.
Solution:
Watch this short video I created for the company I work for.
Using Data Driven Coded UI Test
by Donovan Brown
18. November 2012 04:53
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"/>
by Donovan Brown
3. August 2012 21:06
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:
by Donovan Brown
22. June 2012 20:31
Problem:
I have a test controller in a domain and a test agent in a workgroup and I can’t register the agent with the controller.
Solution:
Create shadow accounts on the agent machine and on the controller machine that are in the Administrators Group. Shadow accounts are accounts with the exact same name and password.
You can test your shadow account by trying to map to a share on the controller machine from the agent machine. Try to access \\controlerMachine\c$ when you are challenged for credentials use the shadow account. Note you may have to disable your firewall to perform this test.
Install and configure the controller on the controller machine. In the Configure Controller dialog use your TFS account and select the project collection. Using Microsoft Test Manager (MTM) under the Lab Center tab verify that your controller is registered on the controller tab.
Second log in to the test agent machine as the shadow account and install and configure the test agent with the test controller. When asked for a user name use the shadow account again. Using MTM refresh the contoller and you should see the Test Agent listed. This machine is now ready to be used in Lab to create a physical environment.
by Donovan Brown
15. December 2011 14:07
Problem:
I get “no suitable method found to override” errors when I mole system.dll.
Solution:
Modify the System.moles file in your project and exclude everything except the types you are trying to mole.
Explanation:
I was trying to mole the SerialPort class in System.IO.Ports. After adding the mole for System.dll I began to get “no suitable method found to override” errors. To resolve this issue I simply double clicked the System.moles file to open it in my IDE. Then I modified the file so that moles were created only for the types under System.IO. Change System.moles from this:
<Moles xmlns="http://schemas.microsoft.com/moles/2010/">
<Assembly Name="System" />
</Moles>
to this:
<Moles xmlns="http://schemas.microsoft.com/moles/2010/">
<Assembly Name="System" />
<StubGeneration>
<Types>
<Clear />
<Add Namespace="System.IO!" />
</Types>
</StubGeneration>
</Moles>
by Donovan Brown
10. October 2011 05:10
Updated (Oct 11, 2011)
Problem:
I have a textbox that has a maximum length of five characters. I want to record a Data Driven CUIT to test that you cannot type in more than five characters. However, when I attempt to set the textbox to a six character value the CUIT throws a PlaybackFailureException.
Solution:
Simply set Playback.PlaybackSettings.SkipSetPropertyVerification = true; before the call that throws the PlaybackFailureException and return it to false after.
Explanation:
After setting a property of any UI control, the record and playback engine performs a verification step to make sure that the set succeeded and the UI control now has the value it attempted to set it to.
For example if you have a text box that only allows 5 characters and you attempt to set it to 6 characters the engine will throw a PlaybackFailureException.
If you are trying to test that if I actually type 123456 that the value is 12345 you will have to set
Playback.PlaybackSettings.SkipSetPropertyVerification = true;
before your test attempts to fill in the value.
by Donovan Brown
3. October 2011 17:03
Problem:
I am not getting code coverage results in my build.
Solution:
Ensure you have a test settings file selected in your build definition.
Explanation:
On the process tab of your build definition expand the Automated Testing section under Basic and make sure the TestSettings File is pointing to the test settings file that has code coverage configured.
You can watch a video below that demonstrates how to do this.