TechBubbles Microsoft Technology BLOG

Creating Code UI Tests in Visual Studio 2010

 

This post discusses about creating a test case for windows application in both Microsoft Test Manager and using a Code UI Test in Visual Studio 2010. It also discuss about editing a Code UI test by adding assertions into the UI map using UI controller.

1. Before creating test case we will create small windows application notepad.

image

2. Add few controls to your windows form like menu bar, toolbar , text box , save dialog and status bar

image

3. Add few lines of code in save button click which saves your content entered in the text area box above

image

4. Now Open the Microsoft Test Center to write a test case for this application

image

5. Click the plan tab and create a new test case by clicking new button

image

Enter the title for test case and enter the action names for the test case like launch application, enter some text and save file in this case. At the end click Save and close.

6. Click the Test tab in test manager and select the test case and click run button

image

7. Click the Start Test when it is prompted

image

8. The first step in our test is launching, launch the application and say passed in test manager as showed below

image 

do the same for other steps in test case and say end test when you finished and then save and close the test case.

image

9. Now come back to Visual Studio 2010 and create a new UI Testcase for the actions we created earlier

image

Here we are using the existing recording for this test case so select this option as shown below

image

10. Select the test case that you have created earlier from the team foundation server

image

11. Now you will be able to see the steps that you have created in test manager

in the code. Select the step and say run from the code or test editor

image  

12. Create a new step in the test case to test the status bar message, whether it is actually saving or not

image

use the UI test mapper to edit the existing test case by clicking the mapper button

image

13. Now drag the UI test mapper to UI element that you want to test and add the assertion to test the save message

image

14. Now add the method name and click save and generate the test case for it

image

15. Now you can see this test case method has added to the code

image

16. To test this test case, go to your application and change the status bar message to not saved and see how our test case behaves. Run the test case then you will see the below message

image

Share this post :

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

Add Comment

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud