改进自动化测试套件的可维护性(三)

发表于:2010-06-13来源:作者:点击数: 标签:自动化维护套件改进
改进 自动化测试 套件的可维护性(三) 软件测试 4.use a framework-based architecture. 4.使用基于框架的架构 The framework provides an entirely different approach, although it is often used in conjunction with one or more data-driven testing str

  改进自动化测试套件的可维护性(三)  软件测试

  4.use a framework-based architecture.

  4.使用基于框架的架构

  The framework provides an entirely different approach, although it is often used in conjunction with one or more data-driven testing strategies. Tom Arnold (one of the LAWST participants) discusses this approach in his book [8] and courses.

  虽然框架通常与一个或一个以上的数据驱动测试策略一同使用,但它本身却提供了一种完全不同的方法。Tom Arnold(LAWST成员之一)在它的书和课程中论述了这种方法。

  The framework isolates the application under test from the test scripts by providing a set of functions in a shared function library. The test script writers treat these functions as if they were basic commands of the test tool’s programming language. They can thus program the scripts independently of the user interface of the software.

  框架通过提供共享函数库中的一套函数,把应用程序从测试脚本中分离。这样,测试脚本编写者在处理这里函数时,就可以把它们视为测试工具的编程语言的基本命令。因此,他们能单独编写软件的用户界面脚本。

  For example, a framework writer might create the function, openfile(p). This function opens file p. It might operate by pulling down the file menu, selecting the Open command, copying the file name to the file name field, and selecting the OK button to close the dialog and do the operation. Or the function might be richer than this, adding extensive error handling. The function might check whether file p was actually opened or it might log the attempt to open the file, and log the result. The function might pull up the File Open dialog by using a command shortcut instead of navigating through the menu. If the program that you’re testing comes with an application programmer interface (API) or a macro language, perhaps the function can call a single command and send it the file name and path as parameters. The function’s definition might change from week to week. The scriptwriter doesn’t care, as long as openfile(x) opens file x.

  例如,一个框架编写者创建了函数openfile(p)。该函数用来打开文件p。它可以通过下拉文件菜单、选择打开命令、复制文件名到文件名域、点击OK按钮关闭对话框来完成操作。此外,这个函数也可以变得更复杂一些,比如,添加可扩展的错误处理功能。它能检查文件p是否已经被打开,或者记录打开文件的尝试以及对结果做日志。该函数还可以用一个命令快捷键,而不是菜单导航来弹出文件打开对话框。如果你的测试程序涉及到一个应用编程接口(API)或宏语言,那么该函数或许能调用一个单独的命令,并把文件名和路径作为参数传递给它。函数的定义经常在变化。但只要openfile(x)能打开文件x,脚本编写者就不必在意。

  Many functions in your library will be useful in several applications (or they will be if you design them to be portable). Don’t expect 100% portability. For example, one version of openfile() might work for every application that uses the standard File Open dialog but you may need additional versions for programs that customize the dialog.

  很多函数库中的函数在一些应用程序中依然有用(或者当它们被设计成可移植的时,也会很有用)。不要指望100%的可移植性。例如,openfile()的某个版本可以在每个应用程序中使用标准文件打开对话框,但你可能需要为那些有定制对话框的程序设计额外的版本。

  Frameworks include several types of functions, from very simple wrappers around simple application or tool functions to very complex scripts that handle an integrated task. Here are some of the basic types:

原文转自:http://www.ltesting.net