1 / 39

Creating Robust, Maintainable Coded UI Tests with Visual Studio 2012

DEV312. Creating Robust, Maintainable Coded UI Tests with Visual Studio 2012 . Brian Keller Sr. Technical Evangelist Microsoft Corporation. I work here…. …on this…. …and this. http://bit.ly/ThisWeekC9. I blog here: http://blogs.msdn.com/briankel. http://tinyurl.com/TFSBook.

Télécharger la présentation

Creating Robust, Maintainable Coded UI Tests with Visual Studio 2012

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.


Presentation Transcript

  1. DEV312 Creating Robust, Maintainable Coded UI Tests with Visual Studio 2012 Brian Keller Sr. Technical Evangelist Microsoft Corporation

  2. I work here…

  3. …on this…

  4. …and this. http://bit.ly/ThisWeekC9

  5. I blog here:http://blogs.msdn.com/briankel

  6. http://tinyurl.com/TFSBook http://tinyurl.com/ALM2010Book

  7. http://tinyurl.com/ALM2012 http://tinyurl.com/ProTFS2012

  8. Objectives • Find more UI regression bugs by employing coded UI tests. • Build and maintain robust coded UI tests. • Create coded UI tests which result in fewer false positives.

  9. What You’ll Need Visual Studio 2012 Premium or Ultimate C# or VB skills Microsoft Test Manager (optionally) Team Foundation Server (optionally) Testable application

  10. Test Automation Platform Support

  11. demo Coded UI Tests

  12. Get Used to Using Using. It’s Useful! using(ApplicationUnderTest.Launch(this.UIMap.LaunchAppParams.UIMyWindowsFormsAppWindowExePath,this.UIMap.LaunchAppParams.UIMyWindowsFormsAppWindowAlternateExePath)) { this.UIMap.SimpleTest(); … } Note: This is required in 2010 only.In 2012, app closes when test run finishes. Use ApplicationUnderTest.CloseOnPlaybackCleanup & BrowserWindow.CloseOnPlaybackCleanup to preserve between test methods.

  13. Understand Searching and Filtering http://tinyurl.com/SearchAndFilter • Searching is used to look for all possible controls • Filtering is used to narrow that list to exactly one match • X, Y is only used to guide where the clicks happen within a control Mouse.Click(uIGOButton, new Point(19, 18));

  14. Test → Windows → Test View → Properties → Select CSV, XML, or Database. this.UIMap.SimpleTestParams.UIMyTextboxEditText = TestContext.DataRow[“col_name"].ToString(); Note: Databinding to test parameters happens automatically when converting from manual test cases Employ Databinding Note: This dialog is currently not available in Visual Studio 2012. Need to hand-edit data connection attributes.

  15. Makes it easier to analyze test run data Assert.AreEqual(foo, bar, "Sales tax total is wrong."); Make Friendlier Assertions

  16. Smile! You’re on Camera Imagepic =this.<top_level_window>.CaptureImage(); //Or for entire desktop: Image pic = UITestControl.Desktop.CaptureImage (); pic.Save(@"c:\file.bmp"); TestContext.AddResultFile(@"c:\file.bmp");

  17. Enable Rich Action Logs QTAgent32.exe.config: <system.diagnostics> <switches> <add name="EqtTraceLevel" value="4" /> </switches> </system.diagnostics><appsettings> <add key="EnableHtmlLogger" value="true"/> <add key="EnableSnapshotInfo" value="true"/> </appsettings>

  18. Microsoft Test Manager → CUIT Workflow Tips • Mark each step as pass/fail when recording manual tests • Carefully consider which test cases make sense for automation, and when • Use the Automation Status field of test cases to identify candidates for automation

  19. For actions that may not happen every time Playback.PlaybackSettings.ContinueOnError= true; Continue on Error or

  20. Multiple UI Map Files http://tinyurl.com/MultipleUIMaps Allows you to separate logical collections of controls • Easier to edit independently • Easier to version control • Requires a bit more up-front effort • Doesn’t play well with MTM workflow

  21. Test API • http://testapi.codeplex.com/ • Input Injection APIs • Command-Line Parsing APIs • Visual Verification APIs • Combinatorial Variation Generation APIs • Managed Code Fault Injection APIs • Text String Generation APIs • Memory Leak Detection APIs • Object Comparison APIs • More…

  22. Coded UI Test Enhanced Frameworkhttp://cuite.codeplex.com/ Simplifies CUIT code • Eliminates need to maintain multiple UI maps • Logical support for tables • Built and supported by the community

  23. Making Your Applications More Testable • Use a testable application stack • Give names to controls • Use naming conventions and stick with them • If you need to change the names of controls, refactor them along with your tests • Carefully consider the implications of changing UI flows • Educate non-test developers on CUITs • Educate manual testers on CUITs

  24. Playback Settings • Search timeouts • Search behaviors • Error behaviors • See http://tinyurl.com/PlaybackSettings

  25. Windows Automation API 3.0 If running an O/S prior to Windows 7/2008 R2, install this platform update: http://support.microsoft.com/kb/971513/

  26. What About Load Testing? • Coded UI tests assume they have “control” of the mouse and keyboard • Load testing can be accomplished but you need one machine (physical or virtual) per virtual user • See http://msdn.microsoft.com/en-us/library/ff468125.aspx

  27. Environments

  28. demo Using Lab Managementwith Coded UI Tests

  29. Go get started! • Download the RC: www.microsoft.com/VisualStudio/11 • Download the ALM VM: http://aka.ms/VS11ALMVM • Ask the Experts, TLC area

  30. tfspreview.com

  31. Related Content Breakout Sessions

  32. Related Content Breakout Sessions

  33. Related Content Breakout Sessions Hands-on Labs (session codes and titles)

  34. Resources Learning TechNet • Connect. Share. Discuss. • Microsoft Certification & Training Resources http://europe.msteched.com www.microsoft.com/learning • Resources for IT Professionals • Resources for Developers • http://microsoft.com/technet http://microsoft.com/msdn

  35. Evaluations Submit your evals online http://europe.msteched.com/sessions

  36. © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related