標籤:
RobotFramework能用Python和Jython兩條腿走路。但有的時候你得選一條。今天就碰上個問題,為了整合其它模組必須用Java實現的DataBaseLibrary
其實實它很簡單,記錄步驟如下: 1.在RF的首頁找到DataBaseLibrary(Java)的首頁。http://code.google.com/p/robotframework-dblibrary/下載dblibrary-1.0.jar 這個庫檔案 2.在Oracle的首頁的download中找到JDBC的驅動程式下載下來(不同版本驅動不同,我用的10g的驅動class12.jar),或者從你安裝的Oracle目錄的jdbc子目錄中找到驅動備用。 3.將這兩個jar檔案全部加入環境變數CLASSPATH 4.在RF裡編寫測試指令碼 串連的例子如下: Database
| Setting |
Value |
| Library |
org.robot.database.keywords.DatabaseLibrary |
|
|
|
| |
|
|
|
|
| Test Case |
Action |
Arguments |
| Test |
Connect to DataBase |
oracle.jdbc.driver.OracleDriver |
jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:sid |
username |
| |
... |
password |
|
|
| |
|
|
|
|
具體使用方式可見使用者手冊:http://robotframework-dblibrary.googlecode.com/svn/tags/robotframework-dblibrary-1.0/doc/DatabaseLibrary.html 兩個Tip:1.為了便於多人使用,建議使用bat動態在Classpath加入Jar包。而不是直接寫到環境變數中(這樣慢慢的你的classpath就亂死了)。給一個參考例子: set CP=%CLASSPATH%for %%j in (*.jar) do ( call :set_cp %%j )set CLASSPATH=%CP% jybot --outputdir ?% --suitestatlevel 1 %* goto :eof :set_cpset CP=%CP%?%\%1;goto :eof 2.這個classLibrary是開源的,寫的很粗糙,覺得不爽可以自己改一改,它的代碼host在google code上可用SVN checkouthttp://code.google.com/p/robotframework-dblibrary/source/checkout
使用RobotFramework的DataBaseLibrary(Java實現)