1. 程式人生 > 實用技巧 >Jmeter請求元件之引數化函式助手_CSVRead和RandomString(十三)

Jmeter請求元件之引數化函式助手_CSVRead和RandomString(十三)

轉載Jmeter請求元件之引數化函式助手_CSVRead和RandomString(十三)

這次例子是個簡單的新增介面,估計叫做註冊介面吧:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import flask,json server = flask.Flask(__name__) all=[] @server.route('/add_user',methods=['post']) def add_user(): user_id = flask.request.values.get('id') username = flask.request.values.get(
'u') if user_id and username: if user_id not in all: all.append(user_id) response = {'code':308,'msg':'註冊成功'} else: response = {'code': 500, 'msg': '註冊失敗'} else: response = {'code':503,'msg':'必填引數未填!'} return json.dumps(response,ensure_ascii=False) server.run(port=8080,debug=True)

  本章是介紹用函式讀取資料:

新增函式助手:

選取函式助手對話方塊裡幾個函式進行介紹:

介面的引數介紹:

準備好txt資料:(一開始準備的csv檔案,但是無法讀取到csv檔案裡的資料,不知道為什麼,所以用txt

將函式字串複製到引數值的地方:

注意的地方:

檢視結果:

RandomString:

函式字串複製到引數的值裡面:

執行,檢視結果:

缺點就是容易重複