During my job I got a new challenge to test an
application with manual and automated process. So I accepted that challenge and
did some hands on with testing. Here I am sharing my experience with my dotnetcodesg.com family. In this
challenge I create some CodedUI test with the help of Visual Studio 2012. So
here I am explaining step by step:
What
is testing?
Testing is used for finding out the bugs in our
application. It helps in finding out the failure of the software before it
crashes the application.
We have 2 type of testing.
1.
Manual Testing
2.
Automation Testing
Software Testing = Manual Testing +
Automation Testing
Manual
Testing: Manual
testing is basically done by user itself without any help of script. Manual software
testing is performed by a human sitting in front of a computer carefully going
through application screens, trying various usage and input combinations,
comparing the results to the expected behavior and recording their observations.
Test management can be taken care of by using test plans and test cases.
Automation
Testing: Automation
testing done by with the help of some automated script and executing the
scripts to run the application with the help of some automation tool. Automated
software testing is the best way to increase the effectiveness, efficiency and
coverage of your software testing.
An automated testing tool is able to playback pre-recorded and predefined actions
compare the results to the expected behavior and report the success or failure
of these manual tests to a test engineer.
Benefits
of Automation Testing:
Testing Improves Accuracy
Increase Test Coverage
Automation Does What Manual Testing Cannot
Automated QA Testing Helps Developers and Testers
Team Morale Improves
What
is Coded UI?
Coded UI is an automation framework which enables us to
record a set of action, creates the code for the same and allows us to playback
the recording for testing the application. It also gives the flexibility to
write the custom code [hand-coded].
Automated tests that drive your application through its
user interface (UI) are known as coded UI tests (CUITs). These tests include
functional testing of the UI controls. They let you verify that the whole
application, including its user interface, is functioning correctly.
Coded UI Tests are particularly useful where there is validation or other logic
in the user interface, for example in a web page. They are also frequently used
to automate an existing manual test.
So what we need to create CodedUI test with Visual
Studio 2012.

Image 1.

Image 2.
Now we will learn step by step How we can create Coded UI test in Visual
Studio 2012.
Open Visual Studio 2012 -> Create New project. ->
Select Test Template -> Coded UI Test Project

Image 3.
Now It will ask you here to record or use an existing
action. I am going to show with new action recording.

Image 4.
After clicking Ok, A small window will appear in right
below side in task bar.

Image 5.
Here you can see 4 buttons on this window.

Image 6.
Now we are going to create a CodedUI test for a
calculator. So click on start recording button like below:

Image 7.
After clicking Recording start button -> Run Command
-> Type Calc

Image 8.
Here you will what action you are going to perform it
will show above CodedUI window.

Image 9.

Image 10.

Image 11.

Image 12.
Now click on pause recording and click on 4th
button to generate code for your actions.

Image 13.
Here give a name to your method.

Image 14.

Image 15.
Here you will see some files and a test Method created.
Coded
UI File Structure : Coded UI maintains a specific file
structure as follows:
CodedUITest.cs
file
UIMap.uitest file
UIMap.Designer.cs file
UIMap.cs file
CodedUITest.cs
file: CodedUITest.cs
file is a unit test file having TestClass decorated with [CodedUITest]
attribute and contains multiple methods decorated with [TestMethod] attribute.
UIMap.uitest
file: UIMap.uitest is
an xml file containing all the windows, controls, properties, methods, actions
and assertions etc used for playback.
UIMap.Designer.cs
file:
UIMap.Designer.cs file is a partial class which contains the classes for
various controls and their fields, properties and methods.
UIMap.cs
file: UIMap.cs is
also a partial class of UIMap.Designer.cs. It can contain all the recorded
methods which need customization.
Now Time to run your test. So you can choose TEST From Menu bar -> Run -> All
test or below option

Image 16.

Image 17.
Now in next I will come with some more example. . .