3

I created a Coded UI Test from a Microsoft Test Manager recording. The exe it runs is the one the tester recorded against.

I want this to be a test I run with my build. How do I change the exe that the coded UI test uses to be the output of:

  1. The TFS Build when a TFS Build is being run
  2. The local build when the test is being run on my machine.

I do NOT need help adding my Coded UI test to my TFS Build. There are several great posts on that already.

I don't have ApplicationUnderTest.Launch. I have this.UIMap.StartApplication(); which then runs generated code (in CodedUI.Designer.cs). Best Practices for Coded UI tests says "Do not edit the UIMap.designer.cs file directly. If you do so, the changes to the file will be overwritten."

2 Answers 2

2
+200

You could add a build configuration to the test project. In that configuration, add a preprocessor definition, PRIVATE_BUILD.

Then, you can use #IFDEF to determine which build to launch:

#ifdef PRIVATE_BUILD ApplicationUnderTest.Launch(pathToPrivateBuild, "", args); #else ApplicationUnderTest.Launch(pathToOfficialBuild, "", args); #endif // PRIVATE_BUILD 

Make sure you don't add that local-only configuration as a flavor for TFS to build during the official build.

Sign up to request clarification or add additional context in comments.

6 Comments

I don't have ApplicationUnderTest.Launch. I have this.UIMap.StartApplication(); which then runs generated code. I would rather not change generated code.
In the MS Best Practices for Coded UI tests it says "Do not edit the UIMap.designer.cs file directly. If you do so, the changes to the file will be overwritten."
OK, I am dumb. Just replace this.UIMap.StartApplication(); with ApplicationUnderTest.Launch.
Everyone kept telling me "just use ApplicationUnderTest.Launch", but heard: "Change the parameter of ApplicationUnderTest.Launch". Sad that I had to waste 200 points cause I can't read. Thank you for the response.
Sorry I didn't get back to you until now :) Depending on which version of VS you have (probably not 2010), you may be able to have custom code in the UI map. In 2010 they now create a partial class, one half of which is created by the designer, the other half is custom, and can be edited. You can copy/paste macros from the generated code into the custom code, remove the reference from the XML file (since in 2010 macros are XML-ized first), and regenerate the code safely and cleanly.
|
0

You can use the Coded UI Test Editor in Visual Studio Feature Pack 2 to visually update the parameter without any coding.

See the following blog post for a tutorial and info on obtaining the extension: http://windotnet.blogspot.com/#!/2011/07/coded-ui-test-editor-is-visual-studio.html

-Paul

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.