Vaccano
Vaccano

Reputation: 82507

Coded UI Test - How to change the exe it runs

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

Upvotes: 3

Views: 2704

Answers (2)

Paul DeCarlo
Paul DeCarlo

Reputation: 416

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

Upvotes: 0

Merlyn Morgan-Graham
Merlyn Morgan-Graham

Reputation: 59151

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.

Upvotes: 2

Related Questions