Articles tagués Code UI Test

Code UI Test in Visual studio 2010 ultimate – Acceptance test in Microsoft

with Ultimate or premium visual studio, you are able to automate your acceptance test or make some User interface test with a recorder provided by

Code UI Test project. Morever, you can customize those test by adding some code, so let’s start with a simple winform project and after create the acceptance test associated:

Create a winform as follows to make an addition:

On designer set textbox and label:

1_designwinform

The code behind on button click will display the addition result :

2_codebehindForCodeUITest

Now, let’s try to test our GUI by first creating a code UI Test :

1/add a test project to our solution (in ultimate version please or premium) and call it as you want 😉

3_addtestproject

2/Notice the test project on solution explorer and delete the UnitTest.cs file:

4_deleteUnitTestFile

3/add a new test:

5_addnewtestCodeUI

4/select a code UI Test

6_CodeUITest

5/ a dialog appears, let the record action checked in order to use a User Interface recorder

Which allows to record every User Interface action and click OK:

7_dialogboxCodeUITestForRecord

6/waw on the left side at the bottom, a tool appears : it is the UI recorder

8_recorderofCodeUITest

7/create a shortcut on your desktop to launch our addition application and press start recording to record the events to start the application (only click on shortcut to launch application):

9_recordwithcodeUITest

8/Press pause to stop recording, click on the right button to notice the event recorded (here only the application launched)

You are able to delete some record steps if there are noise on test.

10_recordedstepinCodeUITest

9/Finally, click on the button at the right side to generate code

11_setMethodforRecordCodeUITest

10/in code ui test the method is generated and allow an automatic launch of our application

12_codegeneratedbyrecorderCodeUITest

11/record and put some addition data here 5 + 5 = 10 :

13_registertestacceptanceeventsrecorder

As you can see all click event and numbers put on application are registred, let’s stop record and  create a method as before:

14_putRecorderMethodforaddingAcceptanceTest

The second is correctly generated in code UI test:

15_codebehindCodeUITest

Now, let’s check that the result is 10 by put the target button by drag and drop on the control label we are interesting:

16_makeanassertiononCodeUITest

As you can see a blue square wrap the control we are interesting and a panel property appears to let us decide on which property we will do an assertion: for sure it is  the display text so select the display text property and click on add assertion button :

17_makeassertioncodeUITest

It is inserted in code test:

18_codebehindcodeUITestwithassertion

Now run the test by selecting it in test view and enjoy the test is automated:

19_runCodeUITestandEnjoy

Waw the test is passed ! we have now to integrate it in a tfs nightly build and the delivery continuous will come faster 😉

, , , , ,

1 commentaire

Microsoft System Center 2012

All System Center 2012 products, Service Manager, App-Controller, Orchestrator, Virtual Machine Manager, Configuration Manager, Data Protection Manager, Operation Manager -Boutougha Hassan

Microsoft Windows Server 2012

IT - Windows server 2012 - Hassan Boutougha

Microsoft Hyper-V

IT - Hyper-V - Hassan Boutougha

Microsoft SQL Server 2012

IT - SQL Server 2012 - Hassan Boutougha