简体   繁体   English

WPF应用程序的测试自动化

[英]Test Automation of WPF Application

We are developing a new WPF application that interacts with a server. 我们正在开发与服务器交互的新WPF应用程序。 The application sends a request to server and gets a response. 该应用程序向服务器发送请求并获得响应。 The response is shown in different ways in different views (ie single model with multiple views). 在不同的视图中以不同的方式显示响应(即具有多个视图的单个模型)。

Now we want to automate the testing of the WPF application. 现在我们要自动化WPF应用程序的测试。 I have the following test-automation needs: 我有以下测试自动化需求:

  1. Validate the request that is sent to server with user-entered parameters. 使用用户输入的参数验证发送到服务器的请求。
  2. Validate the response that is received from the server with the data displayed in multiple views. 验证从服务器接收到的响应以及在多个视图中显示的数据。

Please let me know how to achieve above using any of the Test automation tools. 请让我知道如何使用任何Test自动化工具实现以上目标。

This feature you described is called "Record and Playback". 您描述的此功能称为“记录和播放”。 And as you already mentioned it is quite limited to simple UI interaction and can become difficult in maintaining. 正如您已经提到的,它仅限于简单的UI交互,并且很难维护。

As soon as your interaction logic gets more complex you will have to implement the main parts of your test case logic manually by using a more layered architecture. 一旦您的交互逻辑变得更加复杂,您将必须通过使用更分层的体系结构来手动实现测试用例逻辑的主要部分。 One possible architecture could have the following layers (some of the ideas here are taken from the book Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation ) 一种可能的体系结构可能具有以下几层(此处的某些思想摘自《 持续交付:通过构建,测试和部署自动化进行可靠的软件发布 》一书)

  • The lowest layer would implement the access to the UI controls itself (for example by using one of the UI Test APIs you mentioned.) 最低层将实现对UI控件本身的访问(例如,通过使用您提到的UI测试API之一)。

  • Application driver layer which describes the functionalities of your application. 应用程序驱动程序层,描述您的应用程序的功能。 Here you could have methods like LoginForm.LoginUser(userName,passWord) . 在这里,您可以使用类似LoginForm.LoginUser(userName,passWord) Internally this method could for example handle the complete user input, press all necessary buttons and even do some additional validation if needed (for example if the password has expired and must be retyped). 在内部,此方法可以例如处理完整的用户输入,按所有必需的按钮,甚至在需要时进行一些其他验证(例如,如果密码已过期并且必须重新输入)。 The methods in this layer will access the different UI controls through the lower layer. 该层中的方法将通过较低层访问不同的UI控件。 In general this layer is an abstraction of your application under test. 通常,此层是您正在测试的应用程序的抽象。

  • Use case / Test case layer. 用例/测试用例层。 Here you define the different test steps by calling your application layer. 在这里,您可以通过调用应用程序层来定义不同的测试步骤。

So in your concrete case, you could have a class called ClientSoftware in your Application Driver Layer and this class could have methods like ValidateUserInput or SendRequestToServer . 因此,在您的具体情况下,您可以在应用程序驱动程序层中拥有一个名为ClientSoftware的类,并且该类可以具有ValidateUserInputSendRequestToServer类的方法。 These methods would then implement the necessary UI interaction to execute the desired behavior. 然后,这些方法将实现必要的UI交互以执行所需的行为。 In your test case itself you would then have to setup an instance of the ClientSoftware and call the required methods to implement your test case. 然后,在测试用例本身中,您将必须设置ClientSoftware的实例并调用所需的方法来实现您的测试用例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Windows应用程序驱动程序在UI自动化单元测试期间验证WPF复选框的状态? - How can I verify the state of a WPF checkbox during a UI Automation Unit Test using the Windows Application Driver? 单元测试 wpf 应用程序退出 - Unit test wpf application exit 使用SpecFlow测试WPF应用程序 - Using SpecFlow to test a WPF application 测试运行WPF应用程序的API - Test the API of Running WPF Application 使用 FlaUI 自动化获取 WPF 应用程序中进度条的可见性 - Getting the visibility of a progress bar in a WPF application using FlaUI Automation 使用Inspect.exe进行WinApp驱动程序自动化无法获取WPF应用程序的自动化ID - Unable to get automation id of a WPF application using Inspect.exe for WinApp Driver automation WebBrowser控件自动化C#控制台应用程序测试中的内存泄漏 - Memory leakage in WebBrowser control Automation C# console application test 需要WPF应用程序时如何进行单元测试? - How to Unit Test when the WPF Application is needed? 在测试中为WPF应用程序设置CurrentPrincipal - Setting CurrentPrincipal for a WPF application from within a test WPF:如何测试 Appium 中的应用程序是否最小化 - WPF: HowTo test if application is minimized in Appium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM