現在有找到一個不錯的方式,可以使用 vs 引入 TestStack.White lib 搭配簡單工具,便可以順利快速完成測試程式的開發了。同時也可以順利透過 Jenkins 設定執行。相較於 AutoIt 撰寫的 script 需要逐步加上註解才容易維護, QTP 是個有豐富功能的工具(非 Free,意思是比較複雜一點),引用 lib 方式簡單許多,不用多安裝新工具。
測試專案引用 TestStack.White Library,而 TestStack.White 打包了微軟的 UIAutomation 的測試方式。WinForm 測試的自動化,可讓整合測試更具整合性,WebForm, WinForm 透過自動化測試專案,在Jenkins 上一氣呵成。
• 測試程式範例 GitHub sample code:https://github.com/wellwind/WhiteUiTestingSamples
目前可直接參考 Patricy 為公文檔管驗證 WinForm整理過的專案。
共用平台 ( https://gitpub.gss.com.tw/patricy_chang/D01_020_WinFormTest )
• 下載分析工具 inspect.exe https://docs.microsoft.com/zh-tw/windows/desktop/WinAuto/testing-tools
安裝後它所在的路徑位置 C:\Program Files (x86)\Windows Kits\8.1\bin\x64
取 ClassName,AutomationId(用到下面的程式碼處),這樣程式就可以跑了。
這次測試的 Winform 小程式,大概長這樣: