Loadrunner中java Vuser協議指令碼開發
阿新 • • 發佈:2018-11-05
Loadrunner支援很多協議,其中java Vuser協議也是測試中常用一種協議。
準備:
在使用要java Vuser協議,需要安裝jdk,配置jdk環境變數。
注意:目前loadrunner 11,只支援jdk 1.6以下版本,否則會報如下錯誤:
Error: Java VM internal error:Error Loading javai.dll.
Error: Thread Context: Call to service of the driver failed, reason - thread context wasn't initialized on this thread.
指令碼介紹:
使用java Vuser協議指令碼,其實可以先使用eclipse工具開發和除錯好指令碼,然後複製到LR執行, LR中對java編碼還沒有eclipse方便。
預設java Vuser指令碼如下:
import lrapi.lr;
public class Actions
{
//此init方法是對應c語言時vuser_init檔案,方法名不能修改
public int init() throws Throwable {
return 0;
}//end of init
//對應c語言時action檔案
public int action() throws Throwable {
}//end of action
//對應c語言時vuser_end檔案
public int end() throws Throwable {
return 0;
}//end of end
}
使用技巧:
a.使用java vuser時載入其它第三方jar包或者自定義jar時,
1.在runner-setting進行配置
2.直接在action中,import 對應包及可在程式碼中直接呼叫jar包中方法。
eg: import com.ibm.mq.*;
b.在running-setting也可以手動指定jdk路徑。