TechBubbles Microsoft Technology BLOG

Automated UI Testing with Visual Studio 2012

 
This post discusses about creating a fully automated UI test cases for your application using Visual Studio 2012. You can convert your existing manual tests into fully automated user-interface tests. Without manual intervention you can quickly alert the developers about possible faults in the application. Once you automated your manual tests then you can run the automated tests multiple times in a day or schedule them to run in particular time. In order to write automated UI tests you need to have either Visual Studio premium or ultimate, also you may need to have some basic programming language skills with C# or VB. Optionally you require Microsoft Test manager to define the workflow of tests. image

 

image

Which type of application that Visual Studio support to create automated UI Test cases?

Any web application, Windows Forms or WPF application, also Visual Studio has better integration with third-party vendors to support their controls. Even you can extend your controls to work with coding UI test. The below is the test case to validate that when you start typing an invalid value to the quantity field.

image 

You can turn the above code test case into automated UI test case by creating new test project in Visual Studio 2012

image

When you create above project, you have two options , one is opening Coded UI test builder and start recording your interactions with your application. The other option is start with the test case that already run by the manual tester.

image

click ok and select the test case as shown in the below dialogue

image

It pulls all the test steps associated with the test cases. Most of these steps are auto-generated in the code

image

Now these test methods captures the individual actions that tester was performing when they recorded that test case. You can see the below as an example for clicking the hyperlink in the UI

image

You can also automate the data bound for UI test back to the data parameter and listed values as part of that test case. What does it mean is , it automatically run all the values as part of that test case. Place the cursor in the code where you want to add the validation step then select the TEST menu then Generate Code for Coded UI Test and then click Use Coded UI Test Builder

image

Capture the screen and check the property bag values and add a single assertion for particular field that you want to add the validation

image

You can also add the assertion failure message. You can now generate the code for the above action. close the Test builder and return to Visual Studio then you will notice that method is got added to the steps. You can now say right click on the test and run. It runs for every row of data.

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.

3 Comments

Leave a Reply to kalyanms1 Cancel reply

  • Hi Kalyan,
    How to add a custom error message to the assertion if it fails instead of the generic one? I am using VS 2010, but have seen an option in some of the forums right below the assertion compare value there is one more option to enter the assertion error message, is it not in VS 2010 or am I missing something.
    Thanks
    Kousalya.

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud