[英]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:
我有以下测试自动化需求:
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
的类,并且该类可以具有ValidateUserInput
或SendRequestToServer
类的方法。 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.