If you are not looking to automate your tests everytime your web application is built and deployed then the steps are far easier.
- Create a Build for your Automated Testing Solution.
- In Visual Studio go to your Team Explorer and click on Builds
- Click on New Build Definition
- General Tab
- Fill in Build Definition Name
- Leave Queue Processing Enabled
- Trigger Tab
- I choose Continuous Integration so that it would build every time it was checked in. But pick the one that fits your need the best.
- Source Settings Tab
- You should only need one line with Status Active
- Source Control Folder pointed at the directory your Automated Test Solution is
- Build Agent Folder $(SourceDir)
- Build Defaults Tab
- Select your Build Controller
- In VS 2013 there is an option for Copy build output to the server I found that to be the easiest. If you dont have that option or you have a network share you can use then I would use that. It just needs to be accessible by what ever user you have running your Test Controller and Test Agent.
- Process Tab
- The default .xaml file should have all the pieces you need.
- You should be able to leave everything as defaults with the exception of
- Build -> Projects (Choose your solution for your Automated Test Solution)
- Test -> Advanced -> Disable Tests (True) You dont need them to run everytime you build this.
- Advanced -> Create work item on failure (False) You dont need to change this but most people dont need a ticket everytime a build fails on this type of solution. If you want one you can leave it at True.
- Retention Policy (You can leave it be, or adjust however many builds you want to save)
- Finally Run your build for the first time.
- Assigning the Build to your Test Plan
- Open MTM and go to the Plan Tab inside Testing Center
- Click on Properties
- Make sure that the Automated Runs section has a Test environment selected for it.
- In the Builds Section set your Filter for Builds to the builds with the name of the build you just created
- Next to Build In Use: click Modify and choose the latest build.
- Close and Save your Test Plan
- Link CodedUI Test to MTM Test case.
- Open your Automated Testing Solution in Visual Studio
- Go to Team Explorer and click on Work Items
- Click on new Query and create a query to find your Test case and hit run (I found querying for the ID worked the fastest)
- Open your Test case by double clicking on it
- Go to the Associated Automation tab within your Test Case
- Click on the ... button and select your Test Case.
- If your test case does not show up it may be because either your solution is not open and Built, or you may have multiple TFS projects open and the project you are working out of is not alphabetically first. If you have multiple TFS Projects open I find it best to remove them completely so that they do not show in the Connect to Team and Projects window.
- Finally save your Test case.
At this point you should be able to run it in MTM.
If you update your Automated Test Solution and have it rebuilt remember to go back to your Test Plan in MTM and assign the latest build. I have not figured out how to have it automatically take the latest build.