views:

369

answers:

1

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."

+1  A: 

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.

Merlyn Morgan-Graham
I don't have `ApplicationUnderTest.Launch`. I have `this.UIMap.StartApplication();` which then runs generated code. I would rather not change generated code.
Vaccano
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."
Vaccano
OK, I am dumb. Just replace `this.UIMap.StartApplication();` with `ApplicationUnderTest.Launch`.
Vaccano
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.
Vaccano
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.
Merlyn Morgan-Graham
Also, you could use a custom environment variable, and have the path that AUT.Launch specifies contain that variable. When it gets expanded in the different environments, it can point to different locations. AUT.Launch("%envVar%..., in this case, being inside the generated code :)
Merlyn Morgan-Graham