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.kjueaiud.com/