The Coded UI Test functionality is available in Visual Studio 2010 Premium or Visual Studio 2010 Ultimate.
1. Open Visual Studio 2010
2. Go to File->New->Project
3. Create a new “Test Project” in Visual Studio 2010. I’ve named this one “CalcCodedUITest” under “C:\Projects”.
![](http://lh5.ggpht.com/_fUB3gc9_ZXU/TKCogVozX2I/AAAAAAAAABw/sLYXuKq4Lkk/clip_image002_thumb1.jpg?imgmax=800)
4. Click “OK”.
5. This will create the “Test Project” project with the following file structure:
![](http://lh3.ggpht.com/_fUB3gc9_ZXU/TKCohpBsc0I/AAAAAAAAAB4/BbG0kT1_Cqc/clip_image004_thumb.jpg?imgmax=800)
6. Delete the UnitTest1.cs file and add a Coded UI Test by right clicking on the Project Name -> Add -> New Test and name the new test as “CalcTests.cs”
![](http://lh5.ggpht.com/_fUB3gc9_ZXU/TKCoif7nISI/AAAAAAAAACA/NkNnYbvAJxo/clip_image006_thumb1.jpg?imgmax=800)
7. Click the “Cancel” button on the following screen:
![](http://lh3.ggpht.com/_fUB3gc9_ZXU/TKCokUQl12I/AAAAAAAAACI/Cqyw33OR2DM/clip_image008_thumb.jpg?imgmax=800)
8. Rename the “CodedUITestMethod1()” method to “LoadCalculator()”
9. Place the cursor in the “LoadCalculator” method and right click and select “Generate Code for Coded UI Test -> Use Coded UI Test Builder”
![](http://lh6.ggpht.com/_fUB3gc9_ZXU/TKCoxecE5uI/AAAAAAAAACQ/sZLauRR-URo/clip_image010_thumb1.jpg?imgmax=800)
10. Click the record button to record the test
![](http://lh5.ggpht.com/_fUB3gc9_ZXU/TKCoyjmWthI/AAAAAAAAACY/4qM_C9N9vsY/clip_image012_thumb.jpg?imgmax=800)
11. Type Windows Key + R
12. Type “Calc”
13. Click “OK”
14. Click the “Pause” button to pause the test
![](http://lh6.ggpht.com/_fUB3gc9_ZXU/TKCoz8cKjkI/AAAAAAAAACg/lcWVNkWnd3M/clip_image014_thumb.jpg?imgmax=800)
15. Click the “Show Record Steps” button to review the steps that it has recorded.
![](http://lh6.ggpht.com/_fUB3gc9_ZXU/TKCo0uuT7UI/AAAAAAAAACo/MvVF7ewEqvk/clip_image016_thumb.jpg?imgmax=800)
16. Your steps should look like the following:
![](http://lh3.ggpht.com/_fUB3gc9_ZXU/TKCo1_ojR3I/AAAAAAAAACw/mu0pYHUchxo/clip_image018_thumb.jpg?imgmax=800)
17. Click the “Generate Code” button
![](http://lh3.ggpht.com/_fUB3gc9_ZXU/TKCo412D_TI/AAAAAAAAAC4/7AyomhMqu5w/clip_image020_thumb.jpg?imgmax=800)
18. Name your method. In this example, I named it “LoadCalc”
![](http://lh3.ggpht.com/_fUB3gc9_ZXU/TKCo6doxUGI/AAAAAAAAADA/94c4fQlo2Pc/clip_image022_thumb.jpg?imgmax=800)
19. Click “Add and Generate” button
20. Now the “LoadCalculator” method is now populated with the “this.UIMap.LoadCalc();” statement.
![](http://lh6.ggpht.com/_fUB3gc9_ZXU/TKCo7Pt58XI/AAAAAAAAAGU/wuIG4uK2eWQ/clip_image024_thumb.jpg?imgmax=800)
21. Run the test by placing the cursor in the function, right click in the method and click “Run Tests”
![](http://lh6.ggpht.com/_fUB3gc9_ZXU/TKCo8QcsGsI/AAAAAAAAADQ/nrKlpmQpX9w/clip_image026_thumb.jpg?imgmax=800)
22. If all worked correctly, the system would have loaded the “Calculator” application!
23. Congrats on creating and running your first GUI test!
Download Sample Coded UI Solution