Тестирование UI. Джентельменский набор MVP NUnit NUnitForms RhinoMocks(NMock) Windows PowerShell.

Slides:



Advertisements
Similar presentations
1 Northwind Traders Order Entry. 2 Northwind Traders Call Center Add an Order Entry capability to the Northwind Traders Call Center application. Start.
Advertisements

© Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. HP CarePack registration.
 2007 Dr. Natheer Khasawneh. Chapter 13. Graphical User Interface Concepts: Part 1.
Basic.  Powershell scripts are flat text files that end with “.ps1” (e.g. myscript.ps1)  Similar to other scripting languages, whatever you can do on.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
New ETR actions configurable via UI or PowerShell.
Object-Oriented Analysis and Design
Introduction to Visual Basic Chulantha Kulasekere.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
MS WINDOWS POWER SHELL CSE 535 Operating Systems.
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
Java Beans.
Chapter 3 Using Validation Controls. What is a Validation Control? A control that validates the value in another control Renders as an HTML tag with an.
Introducing the Validation Application Block. Agenda  Enterprise Library 3.0 Introduction  Validation Application Block Overview  Applying, using and.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
V 1.0 Programming III. Creation of additional windows Routed events.
Designing For Testability. Incorporate design features that facilitate testing Include features to: –Support test automation at all levels (unit, integration,
$usercredential= get-credential.
Week 8.  Recap  User Forms  Input Validation Message Boxes Input Boxes  Conversion Functions.
Introduction to Computing Concepts Note Set 11. Other ways of interacting with Java programs There are: ▫ GUI programs ▫ Web-based applets (GUI programs.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 5 Decision Making.
V 1.1 Programming III. Creating additional windows Event handling: preview/routed events.
Test Driven Development Arrange, Act, Assert… Awesome Jason Offutt Software Engineer Central Christian Church
Using Client-Side Scripts to Enhance Web Applications 1.
Section 6: Using Windows PowerShell to Manage Group Policy Introducing Windows PowerShell Windows PowerShell Library for Group Policy Windows PowerShell-Based.
Programming Test #1 Solutions. Multiple Choice 1. B) the grammar of the coding language 2. C) String 3. A) Single 4. C) 2Burgers4Me 5. B) Design Time.
Working with GridView Control: Adding Columns. Adding Buttons to a Bound GridView: 1. Drag the WebProduct table from Data connection to a page 2. Demo.
Sample Application Multi Layered Architecture (n-tier): –Graphical User Interface (GUI): Forms, components, controls The Visual Designer in Visual Studio.
Windows Phone MVVM and Unit Testing Step by Step Andy Wigley Windows Phone Development MVP, Mobile Software Consultant APPA Mundi Ltd WPH208.
CN1266 Network Scripting V1.2 Kemtis Kunanuraksapong MSIS with Distinction MCTS, MCDST, MCP, A+
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
CNS 1410 Graphical User Interfaces. Obectives Students should understand the difference between a procedural program and an Event Driven Program. Students.
C# GUI - Basics. Objectives.NET supports two types: WinForms, traditional, desktop GUI apps. WebForms – newer, for Web apps. Visual Studio.NET supports.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Windows Presentation Foundation (WPF). Introduction Separates appearance of user interface from behavior Appearance usually specified by XAML Behavior.
Input & Output Functions JavaScript is special from other languages because it can accept input and produce output on the basis of that input in the same.
DEPLOYMENT AUTOMATION & CONTINUOUS DEPLOYMENT Szymon Pobiega.
Windows PowerShell Desired State Configuration Overview (for WMF 4.0 Preview) Windows PowerShell Desired State Configuration (DSC) is a new management.
The Start Menu……..Exposed What you never knew existed.
 An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is.
C# - FCL/Form & Control Validation John Kelleher.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
What is Windows PowerShell? The 6 things you must learn.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
Architecture Multi Layered Architecture (n-tier): Application: Model Controllers Database Access Graphical User Interface (GUI): Forms, components, controls.
private void Application_Launching(object sender, LaunchingEventArgs e) { } private void Application_Activated(object.
Basic ActionScript and PHP Cis 126. Getting Started set up a basic folder structure so we can keep our files organized. Mirror this structure on your.
Simple Clicker App WPF App using C#. App Requirement Need a ‘counter’ display, which starts at 0 Need a ‘clicker’ button ! Pressing the clicker every.
Event-Driven Programming F Procedural programming is executed in procedural order. F In event-driven programming, code is executed upon activation of events.
1NetBeans Tutorial Using the “Properties” menu, name the List “List1” and the button “Button1”. NetBeans Tutorial6.
Graphical User Interface Components Version 1.1. Obectives Students should understand how to use these basic Form components to create a Graphical User.
1 Java and AWT CPS 470 Spring 1998 Laura Campbell.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
1 9/15/05CS360 Windows Programming Event, Exceptions, Message Boxes, and Forms.
COMP 365 Android Development.  Developing for Android  XML for user interface formatting and other scripting  Java for programming.
Beginning ASP.NET in C# and VB Chapter 9
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Andy Wigley Device Application Development MVP APPA Mundi Ltd SESSION CODE: WEM309.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
Beyond Basic Unit Testing: Mocks, Stubs, User Interfaces, and Refactoring for Testability Benjamin Day
GUI Programming Prepared by: Ahmad Ramin Rahimee Assistant Professor ICTI.
1998 PI System Users’ Conference PI-DataLink New Features of PI Users’ Conference Joe Mishaga & Ling Mok.
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Predefined Dialog Boxes
Chapter 1 Minitab Recipe Card
Based on Murach Chapter 10
6. WinForms 2003 C# GUI - Basics.
Process Exchange Transactions Activity
Presentation transcript:

Тестирование UI

Джентельменский набор MVP NUnit NUnitForms RhinoMocks(NMock) Windows PowerShell

Тестирование UI Код, который легко тестировать Тесты, которые легко «кодить»

Model View Controller Model View Controller

Model View Controller Model Controller Display logic Presen- tation logic View

MVP Model View Presenter Event/Observer Model View Presenter

MVP public interface IOrderView { string Name {get;set;} int Amount {get;set;} void ShowMessage(string message); event VoidDelegate Cancel; event VoidDelegate Save; } public interface I Service { bool Send (string , string text); } Model View Presenter

MVP public class OrderPresenter { private I Service service; private IOrderView view; public OrderPresenter(I Service service, IOrderView view) { this.view = view; this.service = service; view.Save += view_Save; } void view_Save() { Order order = new Order(view.Name, view.Amount); if(order.Amount > 1000) "Order amount > 1000"); //Process order... } Model View Presenter

State-based тестирование Тестирование «чистых» функций Тестирование компонентов с малым числом зависимостей Тестирование компонентов обладающих «простыми состояниями»

State-based тестирование public class StateBasedUnitTest { public void DoTest() { Calculator calc = new Calculator(); int res = calc.Sum(10, 20); Assert.AreEqual(res, 30); }

К сожалению, Presenter… Не предоставляет «чистых функций» Будучи по своей природе «медиатором», зависит от большого числа компонентов Тестировать состояние Presenter-а абсолютно бесмысленое занятие

Пример тестового сценария Сотрудник вводит в форму «Создание заказа» название и стоимость заказа Пользователь нажимает кнопку «Сохранить заказ» Если стоимость заказа превышает 1000 рублей, то посылается главному менеджеру для проверки заказа Заказ сохраняется в системе Пользователю сообщается, что заказ успешно сохранился в системе

public void DoTest() { MockRepository mocks = new MockRepository(); //Создание mock-объектов I Service Service = mocks.CreateMock (); IOrderView view = mocks.CreateMock (); //Начало записи сценария view.Save += null; IEventRaiser raiser = LastCall.IgnoreArguments().GetEventRaiser(); using(mocks.Unordered()) { Expect.Call(view.Name).Return("Beer"); Expect.Call(view.Amount).Return("1001"); } Expect.Call( Service.Send ("", "")).IgnoreArguments(); Expect.Call(view.ShowMessage("")).IgnoreArguments(); //Проигрываем сценарий и проверяем соответствие записанному mocks.ReplayAll(); OrderPresenter presenter = new OrderPresenter( Service, view); raiser.Raise(); mocks.VerifyAll(); } Реализация interaction-based тестирования с RhinoMocks

NUnitForms public void Test() { Form1 form = new Form1(); form.Show(); TextBoxTester tbxName = new TextBoxTester("Name2"); TextBoxTester tbxAmount = new TextBoxTester("Amount2"); ButtonTester btnOK = new ButtonTester("btnOk"); FormTester appForm = new FormTester("Form1"); ExpectModal("Message", delegate { MessageBoxTester messageBox = new MessageBoxTester("Message"); messageBox.ClickOk(); }); tbxName.Enter("Beer"); tbxAmount.Enter("1001"); btnOK.Click(); form.Dispose(); }

Windows PowerShell Windows PowerShell™ — это новая командная оболочка Windows, разработанная в первую очередь для системных администраторов. Она включает интерактивную командную строку и среду исполнения сценариев.

Windows PowerShell Понятие командлета(сmdlet) в Windows PowerShell Создание своих командлетов на.Net Использование готовых библиотек Cmdlet-ов для автоматизации тестирования UI

Custom Cmdlets for UI Automation Cmdlet NameInput ParametersReturn Value / Effect get-windowwindowNameHandle to a top-level window get-controlhandleParent, ctrlNameHandle to a named control get-controlByIndexhandleParent, indexHandle to a non-named control send-charshandleControl, sSends string s to a control send-clickhandleControlClicks a control get-listBoxhandleControl, targetZero-based location of target get-textBoxhandleControlContents of TextBox as a string send-menumainIndex, subIndexFires application menu command.

Windows PowerShell # Test.ps1 write-host "Start test" $testPassed = $true invoke-item 'TestApp.exe' [System.Threading.Thread]::Sleep(2000) #get handlers $app = get-window "TestApp" $tbxName = get-control $app "Name" $tbxAmout = get-control $app "Amount" $btnOk = get-control $app "Ok" #init form send-chars $tbxName "Beer" send-chars $tbxAmout "1001" send-click $btnOk #... #get message box [System.Threading.Thread]::Sleep(2000) $mBox = get-window "Message" if( $mBox –eq $null ) { write-host “Test failed” } else { write-host "`Test passed" } write-host "End test" # end script

Windows PowerShell public class TestScript { public string CreatedBy{...} public string DateCreated{...} public int Priority{...} public string Tags{...} public int ExecutionTime{...} public int LastExecutionTime{...} } [Cmdlet(VerbsLifeCycle.Start, "TestScripts")] public class ExecuteScripts : Cmdlet {... private void executeScripts(TestScript[] scripts){...} } [Cmdlet(VerbsCommon.Get, "TestScripts")] public class GetScripts : Cmdlet {... private TestScript[] findScripts(string path){...} }

PS C:\> Get-TestScripts –Path.\MyTests | Where-Object -FilterScript {($_.Tags -contains "Order") -or ($_. Tags -contains "Customer")} | Execute-TestScripts PS C:\> Get-TestScripts –Path.\MyTests | Where-Object -FilterScript {($_. Tags -contains "Order")} | Sort-Object -Priority -Descending | Execute-TestScripts PS C:\> Get-TestScripts –Path.\MyTests | Where-Object -FilterScript {($_.Tags - contains "Order") –and ($_.CreatedBy -eq “Maxim") } | Sort-Object -CreatedTime -Descending | Execute-TestScripts Windows PowerShell

Коротков Максим, Finance Software Windows PowerShell