Sponsored Ad

Tuesday, May 4, 2010

How to Create and Run Coded UI Test in VS2010

VS2010 is now available for use and it have very good testing features in it.

Coded UI test is good feature provided by VS2010 to Record and play actions. This is very helpful for manual testers and developers to automate the testing process.

 

Let’s go through it by step by step procedure.

Step 1: Create a windows project using Visual studio 2010.

Create a windows project

 

Step 2: Create a multiplication application which takes two input from textbox and given multiplication in third textbox.

vs2010 application

 

Step 3: Add a test project in this solution by right click on solution -> add - >New Project, from the options select Test Project (Test Document). Click ok it will add a new test project in your application.

Add new test project in VS2010

 

Step 4: Right click on newly created test project and add -> Coded UI Test , The Code UI test file will be added.

Add Coded UI Test

 

Step 5: Generate code for coded UI test screen will display , here you can select if you want to use existing recorded project or want to create new record project.

Select record action option in coded UI test

 

Step 6: Record screen is available now. Click on start recording, orange button.

Strun project without debugging vs2010

Action Recorder in Coded UI Test

 

Step 7: run the project in without debugging mode. And enter values and click on “Click” button, result appears.

Fill values in running project

 

Step 8: Click highlighted button to check recorded actions.

Check Recorded Actions

Recorded Actions

 

Step 9: to generate recorded code click on below highlighted button.

Generate Code for Recorded actions in vs2010

Given the name to method

 

Step 10: Now drag and drop the blow highlighted button to tired text box ( 44 one). Now add assertion window appears, go to text property and right click -> add assertion .

Add Assertion in VS2010

Add Assertion

 

Step 11: value and operator appears, here you can define the criteria (equal , greater etc). click ok.

Add assertion - compare operators

 

Step 12: Code for recorded action and assertion is generated. Now in below careen you can see that our all the values 22, 2, 44 are there.

Recorded action generated code - vs2010

 

Step 13: Now let’s try by running it go to test-> debug - > All tests in solution

It will start filling those values in running screen, like you can see in below screen. After running the test it will show the test results both results are pass.
Run coded Ui test in VS2010

 

Run coded UI test - pass

 

Step 14: Now lets go to code and change value of second textbox 2-> 3

Change the values for coded UI test - vs2010

 

Step 15: lets run the test again by test-> debug - > All tests in solution

Run coded UI Test - Fail

Now you can see that test is failed and error message showing

Failed CodedUITestMethod1 MyTestProject Assert.AreEqual failed. Expected:<44>. Actual:<66>.

Which means that it is testing outcome as 44 while the result is 66.

0 comments:

Post a Comment

Related Software Testing Articles



Website List