重構是維護程式碼的一個重要過程,當一段程式碼持續增加新功能時,程式碼的品質會不斷下降,這時就有可能出現壞味道,而將這段程式碼重構可以幫助提升程式的品質,消除程式碼上的壞味道,使程式碼的架構變得更好、更容易理解。一個GUI測試腳本記錄了「對待測程式的GUI進行操作及驗證的動作」,而測試腳本與程式碼類似,也可能出現壞味道,此時重構為一個良好的方法,可以消除GUI測試腳本上的壞味道,使其架構變得更好、容易維護。然而,過去並沒有對GUI測試腳本重構的研究。本論文探討如何應用重構方法在GUI測試腳本上,包括(1) 定義GUI測試腳本上可能出現的壞味道; (2) 定義適用於GUI測試腳本的重構方法。此外,本論文也實作出一套適用於GUI測試腳本的自動化重構工具,讓測試人員可以使用重構工具對GUI測試腳本進行重構,改變GUI測試腳本的架構,使GUI測試腳本更容易理解、更容易維護。
Refactoring is an important part of software maintenance processes. When one continuously adds new functions to a program, the code quality may be degraded. And the code may have “bad smells,” which indicate deeper problems of the program. By refactoring the code, we can remove the smells and, therefore, improve the design as well as overall code quality. A GUI test script records “operations and verifications of the GUI.” Like a program, a GUI test script may also have bad smells and refactoring is a good way to remove the smells. So far, no researches have studied the refactoring of GUI test scripts. This thesis studies how to apply refactoring methods to GUI test scripts, including: (1) define the smells that a GUI test script may have; (2) define refactoring methods for GUI test scripts. In addition, this thesis also develops an automatic refactoring tool for GUI test scripts. With the help of the tool, bad smells in GUI test scripts can be easily removed, and the GUI test scripts become more understandable and maintainable.