RF 是最強(qiáng)的自動(dòng)化測(cè)試框架, 沒(méi)有之一!
前置條件
- 已安裝 Python2.7
- 已安裝好 Robot Framework 框架和相關(guān) Python2.x 測(cè)試庫(kù)
- 任何安裝目錄中都不要出現(xiàn)中文
一、安裝配置 Sublime Text 3
- 在 Sublime 官網(wǎng)根據(jù)自己的系統(tǒng)下載并安裝相應(yīng)版本的 Sublime Text 3;
- 根據(jù) Package Control 官網(wǎng) 的說(shuō)明安裝該插件。
二、安裝配置 RobotFrameworkAssistant
說(shuō)明文檔:https://packagecontrol.io/packages/RobotFrameworkAssistant
GitHub 地址:https://github.com/andriyko/sublime-robot-framework-assistant
1. 安裝 RobotFrameworkAssistant
安裝過(guò)程圖示:

2. 配置 RobotFrameworkAssistant
2.1 打開 Robot.sublime-settings 文件,注意選擇 Setting - User:

2.2 修改 Robot.sublime-settings 文件并保存:

示例代碼如下:(代碼中的相關(guān)路徑需要修改為自己機(jī)器中的實(shí)際路徑)
- Windows
/*
Robot Framework Assistant User settings for panfeng
*/
{
"path_to_python": "C:\\Python27\\python.exe",
"robot_framework_workspace": "D:\\OneDrive\\TesterScript\\RF",
"robot_framework_module_search_path":
[
"C:\\Python27\\Lib\\site-packages",
],
"robot_framework_keyword_argument_format": true,
}
- Mac
/*
Robot Framework Assistant User settings for panfeng
*/
{
"path_to_python": "python3",
"robot_framework_workspace": "/Users/panfeng/workspace/RF",
"robot_framework_module_search_path":
[
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages",
],
"robot_framework_keyword_argument_format": true
}
注意:和 Python 有關(guān)的路徑需要設(shè)置為 Python 2.x 版本,截止到目前 2018.07.16, Robot Framework Assistant 的 Python3 版本兼容性不是很好。
2.3 安裝配置完成后大致效果如下:(主題和字體可能不一樣)

2.4 打開 Robot.sublime-build 配置文件:

2.5 修改 Robot.sublime-build 配置文件并保存:

示例代碼如下:
- Windows
{
"cmd": ["python", "-m", "robot.run", "-d", "log", "$file"],
"selector": "source.robot",
"variants": [
{ "name": "Selects the test cases by tag",
"cmd": ["python", "-m", "robot.run", "--include", "REPLACE_WITH_TAG", "-d", "log", "$file"],
},
{ "name": "Selects the test cases by name",
"cmd": ["python", "-m", "robot", "--test", "REPLACE_WITH_TEST_NAME", "-d", "log", "$file"]
}
]
}
- Mac
{
"cmd": ["python3", "-m", "robot", "-d", "log", "$file"],
"selector": "source.robot",
"variants": [
{ "name": "Selects the test cases by tag",
"cmd": ["python3", "-m", "robot", "--include", "REPLACE_WITH_TAG", "-d", "log", "$file"],
},
{ "name": "Selects the test cases by name",
"cmd": ["python3", "-m", "robot", "--test", "REPLACE_WITH_TEST_NAME", "-d", "log", "$file"]
}
]
}
2.6 配置完成后即可通過(guò) Sublime 的構(gòu)建系統(tǒng)執(zhí)行腳本

完成上述操作后,Sublime Text 3 便可以高亮顯示 RF 語(yǔ)法,并進(jìn)行相關(guān)層次的構(gòu)建操作。但還不具備關(guān)鍵字自動(dòng)補(bǔ)全的功能,想要讓 Sublime Text 3 可以進(jìn)行關(guān)鍵字自動(dòng)補(bǔ)全,還需要進(jìn)行 Database 的創(chuàng)建。
4. 創(chuàng)建 Database
創(chuàng)建 Database 的操作十分簡(jiǎn)單,只需要通過(guò) 導(dǎo)航欄 Preference --> Package Setting --> Robot Framework Assistant --> Create Datebase 或 右鍵打開的 RF 文件 --> Robot Framework --> Datebase --> Create Datebase 進(jìn)行創(chuàng)建即可。


創(chuàng)建成功后,左下角應(yīng)該會(huì)顯示
Indexing done with rc: 0 ,也可以通過(guò)打開 RobotFrameworkAssistant 插件目錄(默認(rèn)在 C:\Users\用戶名\AppData\Roaming\Sublime Text 3\Packages\RobotFrameworkAssistant\database)下的 database 查看是否創(chuàng)建成功,如果創(chuàng)建成功則會(huì)生成 index 和 scanner 兩個(gè)文件夾。
最終效果:

個(gè)性化 Sublime Text 3 配置,讓 Sublime 更加美觀(可選)
主題:ayu
字體:Roboto Mono Medium
(谷歌字體下載需要 fq)
http://m.itdecent.cn/p/07ae62d2c63f
如需轉(zhuǎn)載請(qǐng)注明出處!