Jaa


Creating an automated test from a manual test with Visual Studio 2010

I really like the capability to create automated tests from manual tests in Visual Studio 2010. I’ve been playing with it a little recently and I though it was worth quickly running through it as it joins up the use of Test Manager and Coded UI Tests in Visual Studio. The scenario I would have in mind is that, as a tester, I’ve created a manual test case and, probably after a bug is discovered and fixed in that test case, I later want to automate the test. Rather than having to start again with the automated test, it’s possible to use the manual test to create the core of the automated test.

The key to being able to do this is “action recording”. Action recording captures the actions (interactions with the application under test) and allows these to be used to “fast-forward” through a manual test. This might sound like automated testing, but the difference is that an action recording doesn’t verify if a step or test has passed, it simply automates the navigation to the points at which the tester can make a decision about pass or fail.

Step 1 – Enable action recording in your test plan

image

In Test Manager, in Plan mode, select the test plan and click on properties

image

In the test plan, open up the test settings (your may be called something else, this was my name for my test settings).

image

Make sure that the Action Recording is enabled.

Step 2 – Run the manual test with Action Recording running

image

Run the manual test, and check the Create action recording option.

image

You can see the action recording steps as you go, although you’ll need to click on the up chevron to see them. (Note you can delete lines from the action recording if you want).

Step 3 – Create a Coded UI test based on the action recording

image

Create a new Coded UI Test

image

When prompted, select Use an existing action recording

image

In the work item picker, choose the Team Project that the test cases live in, run a query (such as Open Test Cases) and select the test case that includes the action recording just recorded.

image

The codified form of the action recording will now be added into the Coded UI Test. This will work and if you run this test the application will be opened and the steps completed. All done? Not quite. To complete this you will probably want to add in verification points so that the test is truly determining if the case passed or not. You can do this by using the Coded UI Test Builder to add in a verification point. To do this, right click at the step where you want to insert the verification:

image

Open your application and select the Verification icon from the Coded UI Test Builder:

image

Drag this onto the relevant control in the application under test and set the appropriate verification check:

image

Generate the method code for this assertion:

image

The automated test now includes (at least one) verification step and this test is now completely automated, without having had to record it.

I’ve missed out a lot of minor details but hopefully this is enough to show how you could use this capability to help promote manual test to automated tests.

Cheers,
Giles

Technorati Tags: Visual Studio,2010,Test Manager,Action Recording,Manual Test,Coded UI Test

Comments

  • Anonymous
    February 10, 2010
    Great walkthrough!

  • Anonymous
    November 13, 2012
    This is a brilliant walkthrough, thank you.  I knew the basics of codedUI automation but knew nothing about the Assertions part, seems easy enough, thanks again.