Coded UI
in a nutshell
Omer Karpas
Abbreviations and Professional Terms
(Glossary)
Abbreviation or term Definition
KDT Keywords Driven Testing
AUT Application Under Test
VS Visual Studio
BB Building Block
GUI Graphical User Interface
VB Visual Basic
CUIT Coded UI Test
TC Test Case
Scenario Synonym for Test Case
Keyword Driven Testing
 In KDT (keyword-driven testing), each keyword
corresponds to an individual testing Action or Verification.
 Examples:
 A mouse click
 Selection of a menu item
 Keystrokes
 Opening or closing a window
 Verifying a control is visible
 Verifying a control is enabled
 Etc…
Keyword Driven Testing
 A keyword-driven test is a sequence of keywords, that
simulate user actions on the AUT (Application Under Test).
 Basically, to create a test, testers simply order the
corresponding keywords of the desired Actions and
Verifications.
 Keywords are commonly called Modules or BB
(Building Blocks).
Keyword Driven Testing
 Pros:
 Reuse of code
 Allows non-coding personals to build scenarios from the
BB.
 Much easier maintenance
 Cons:
 Takes more coding time
 Conclusion – KDT is the way to go!
Microsoft Coded UI
Framework
 “You can use Visual Studio 2010 Ultimate or Visual
Studio 2010 Premium to create automated tests of the
user interface (UI) known as coded UI tests. These tests
provide functional testing of the user interface and
validation of user interface controls. Automated UI
tests enable you to test that the user interface is
functioning correctly after code changes. They are
quicker to run than manual tests. Therefore, you can
run them more frequently.“ (MSDN)
Microsoft Coded UI
Framework
 Coded UI is a Framework designed to provide
developers a way to:
 Interact with the AUD (application under test) Controls, to
get their state, values etc..
 Interact with the AUD (application under test) Controls, to
Set their state, values etc..
 Run their automatic TC (Test Cases).
Microsoft Coded UI
Framework
 Coded UI is a Framework can handle Controls of the
following types:
 WinForms
 HTML
 WPF (Windows Presentation Foundation)
 This is a big advantage of Coded UI because currently
the only other tool that handles Custom controls of
WPF is QTP.
Microsoft Coded UI
Framework
 Coded UI tests can be written in VB.NET (Visual Basic)
or in C# (C-Sharp).
 Coded UI tests can be run manually or automatically.
 Coded UI tests can be coded manually or by
recording Tests using the Coded UI Test Builder.
Microsoft Coded UI
Framework
 Using the KDT approach is up to the developer.
 Coded UI framework have very limited special
features to support coding with KDT in mind, but it is still
highly recommended.
Recording VS Manually
Automating
 In general, there are two ways to create Automatic
tests with the Coded UI framework.
 The first way is by using the “Coded UI Test Builder”
 recording your actions on the AUT and adding
assertions(Verifications) – all without any coding involved.
 In theory that could be great but unfortunately, currently, the
framework is not sufficient in recognizing custom controls,
and mapping large scale applications.
 Thus, this way is not applicable to our needs.
Recording VS Manually
Automating
 Moreover, even if the recording capabilities would meet our
needs, this way is not compatible with our KDT approach,
because, we will need to record each scenario from start to
end (no reuse of code).
 For example, if we need to add another step to some of our
CUITs, we will need to record those tests again, from scratch,
or we will need to manually code those actions and copy
past the code across all tests,
 Instead, by using KDT, we would just update one of our
Modules.
Recording VS Manually
Automating
 The second way is by implementing the code
manually.
What you need
(Prerequisites)
 Visual Studio 2010 Ultimate or Visual Studio 2010
Premium or newer versions of Visual Studio.
 SQL express (can be installed as part of the VS2010
installations).
Creating a new Coded UI Project
 Open Microsoft Visual Studio 2010 Ultimate (or newer)
 Start a new testing project: “File” -> “New Project…” .
 In the New Project window, select “Visual C#”->
“Test”, enter a name for the Project and press the OK
button to create the test project.
Creating a new Coded UI Project
Creating a new Coded UI Project
 Close the “UnitTest.cs” window
 R.click on the “UnitTest.cs” in the “Solution Explorer”
and select Delete.

Coded ui in a nutshell

  • 1.
    Coded UI in anutshell Omer Karpas
  • 2.
    Abbreviations and ProfessionalTerms (Glossary) Abbreviation or term Definition KDT Keywords Driven Testing AUT Application Under Test VS Visual Studio BB Building Block GUI Graphical User Interface VB Visual Basic CUIT Coded UI Test TC Test Case Scenario Synonym for Test Case
  • 3.
    Keyword Driven Testing In KDT (keyword-driven testing), each keyword corresponds to an individual testing Action or Verification.  Examples:  A mouse click  Selection of a menu item  Keystrokes  Opening or closing a window  Verifying a control is visible  Verifying a control is enabled  Etc…
  • 4.
    Keyword Driven Testing A keyword-driven test is a sequence of keywords, that simulate user actions on the AUT (Application Under Test).  Basically, to create a test, testers simply order the corresponding keywords of the desired Actions and Verifications.  Keywords are commonly called Modules or BB (Building Blocks).
  • 5.
    Keyword Driven Testing Pros:  Reuse of code  Allows non-coding personals to build scenarios from the BB.  Much easier maintenance  Cons:  Takes more coding time  Conclusion – KDT is the way to go!
  • 6.
    Microsoft Coded UI Framework “You can use Visual Studio 2010 Ultimate or Visual Studio 2010 Premium to create automated tests of the user interface (UI) known as coded UI tests. These tests provide functional testing of the user interface and validation of user interface controls. Automated UI tests enable you to test that the user interface is functioning correctly after code changes. They are quicker to run than manual tests. Therefore, you can run them more frequently.“ (MSDN)
  • 7.
    Microsoft Coded UI Framework Coded UI is a Framework designed to provide developers a way to:  Interact with the AUD (application under test) Controls, to get their state, values etc..  Interact with the AUD (application under test) Controls, to Set their state, values etc..  Run their automatic TC (Test Cases).
  • 8.
    Microsoft Coded UI Framework Coded UI is a Framework can handle Controls of the following types:  WinForms  HTML  WPF (Windows Presentation Foundation)  This is a big advantage of Coded UI because currently the only other tool that handles Custom controls of WPF is QTP.
  • 9.
    Microsoft Coded UI Framework Coded UI tests can be written in VB.NET (Visual Basic) or in C# (C-Sharp).  Coded UI tests can be run manually or automatically.  Coded UI tests can be coded manually or by recording Tests using the Coded UI Test Builder.
  • 10.
    Microsoft Coded UI Framework Using the KDT approach is up to the developer.  Coded UI framework have very limited special features to support coding with KDT in mind, but it is still highly recommended.
  • 11.
    Recording VS Manually Automating In general, there are two ways to create Automatic tests with the Coded UI framework.  The first way is by using the “Coded UI Test Builder”  recording your actions on the AUT and adding assertions(Verifications) – all without any coding involved.  In theory that could be great but unfortunately, currently, the framework is not sufficient in recognizing custom controls, and mapping large scale applications.  Thus, this way is not applicable to our needs.
  • 12.
    Recording VS Manually Automating Moreover, even if the recording capabilities would meet our needs, this way is not compatible with our KDT approach, because, we will need to record each scenario from start to end (no reuse of code).  For example, if we need to add another step to some of our CUITs, we will need to record those tests again, from scratch, or we will need to manually code those actions and copy past the code across all tests,  Instead, by using KDT, we would just update one of our Modules.
  • 13.
    Recording VS Manually Automating The second way is by implementing the code manually.
  • 14.
    What you need (Prerequisites) Visual Studio 2010 Ultimate or Visual Studio 2010 Premium or newer versions of Visual Studio.  SQL express (can be installed as part of the VS2010 installations).
  • 15.
    Creating a newCoded UI Project  Open Microsoft Visual Studio 2010 Ultimate (or newer)  Start a new testing project: “File” -> “New Project…” .  In the New Project window, select “Visual C#”-> “Test”, enter a name for the Project and press the OK button to create the test project.
  • 16.
    Creating a newCoded UI Project
  • 17.
    Creating a newCoded UI Project  Close the “UnitTest.cs” window  R.click on the “UnitTest.cs” in the “Solution Explorer” and select Delete.