CUIT with Visual Studio and TFS TechEvent 2014 Thomas Gassmann Daniel Steinlin BASEL BERN BRUGG LAUSANNE ZUERICH DUESSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MUNICH STUTTGART VIENNA 1
AGENDA 1. What are CUIT? 2. Data Driven UI Tests 3. CUIT and Test Manager 4. CUIT for Web Applications 5. Conclusion 6. Questions 2
What are CUIT? 3
Coded UI Tests Coded UI Tests are automated tests that drive your application through its user interface. Used to automate testing from the user interface Test development and maintenance in Visual Studio Integration in TFS, Build Server, etc. Generate code in C# / VB Works for Windows applications as well as for Web applications 4
Integration in Visual Studio 5
Creating Coded UI Tests Generating your Coded UI Test from an existing recording Generating a new Coded UI Test from scratch using Coded UI Test Builder (integrated in Visual Studio) Writing your own Coded UI Test 6
Demo 7
Generated Coded UI Files Filename CodedUITest1.cs UIMap.uitest UIMap.designer.cs UIMap.cs Description Contains the coded UI test class, test methods and assertions. Contains the XML model for the UIMap class, including all windows, controls, properties, methods, parameters, actions and assertions. Contains the code representation of the XML contained in the UIMap.uitest file. Contains more of the code for the UIMap class. Put any customizations for the UIMap in this file. 8
Coded UI Test Builder Generate Code Add Assertions Edit Recorded Steps Record/Stop/Pause 9
Code Snippets Start a new instance of an application var app = ApplicationUnderTest.Launch("PATH"); Highlight a control textbox.drawhighlight(); Capture Image UIMap.MyWindow.CaptureImage().Save(System.IO.Path. Combine(TestContext.TestRunResultsDirectory, "NAME.PNG") ); Send keys to a control Keyboard.SendKeys(textbox, "Hello World!"); 10
Data Driven Tests 11
What are «Data Driven» Tests? You can run test cases multiple times using different sets of data You can use MTM Test Case items as data source, as well as XML, CSV, Excel and SQL 12
Data Source Types Data Source Type Test case in TFS CSV Excel XML SQL Data Source Attribute [DataSource("Microsoft.VisualStudio.TestTools.DataSource.TestC ase", "http://vlm13261329:8080/tfs/defaultcollection;agile", "30", DataAccessMethod.Sequential), TestMethod] [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", " DataDirectory \\data.csv", "data#csv", DataAccessMethod.Sequential), DeploymentItem("data.csv"), TestMethod] DataSource("System.Data.Odbc", "Dsn=Excel Files;Driver={Microsoft Excel Driver (*.xls)};dbq= DataDirectory \\Data.xls;defaultdir=.;driverid=7 90;maxbuffersize=2048;pagetimeout=5;readonly=true", "Sheet1$", DataAccessMethod.Sequential), TestMethod] [DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", " DataDirectory \\data.xml", "Iterations", DataAccessMethod.Sequential), DeploymentItem("data.xml"), TestMethod] [DataSource("System.Data.SqlClient", "Data Source=.\\sqlexpress;Initial Catalog=tempdb;Integrated Security=True", "Data", DataAccessMethod.Sequential), TestMethod] 13
Demo Data Driven Tests 14
CUIT and Test Manager 15
Architecture Landscape TE2014.local domain Test Agent Windows 8.1 Client DC TFS App Server Build Server SQL Server Register with Team Project Collection Test Controller 16
CUIT and Test Manager Create a build to compile Configure a test case in MTM Connect the CUIT with the test case Run the test in our dedicated test environment 17
Demo CUIT and Test Manager 18
CUIT for Web Applications 19
CUIT for Web Applications Access to the whole DOM tree Recording feature only available in IE9+ Possibility to test different browsers 20
Demo CUIT for Web Applications 21
Conclusion 22
Conclusion Coded UI tests are a great way to automatically or manually test your application, especially the GUI are fully integrated in Visual Studio and Team Foundation Server support the latest technologies like Windows Store Apps are a simpler way to analyse errors through automated test recording are more efficent through test automatisation are a simplification of stress and load testing reduce the number of non-reproducible errors 23
Further information... Frameworks http://cuite.codeplex.com/ Best practices for CUIT http://msdn.microsoft.com/en-us/library/dd380782.aspx Online training http://beta.pluralsight.com/courses/codedui-test-automation 24
Questions and answers... Daniel Steinlin Consultant Tel.: +41-58-459 50 89 daniel.steinlin@trivadis.com Thomas Gassmann Consultant Tel.: +41-58-459 52 81 thomas.gassmann@trivadis.com BASEL BERN BRUGG LAUSANNE ZUERICH DUESSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MUNICH STUTTGART VIENNA 25