jmeter的使用--添加自定義函數和導入自定義jar


1、添加自定義函數,增加  號碼生成函數 MobileGenerator和身份證生成函數IdCardGenerator

     在package org.apache.jmeter.functions;中增加自定義函數,詳細參照代碼:https://gitee.com/hongyeao/jmeter-hh

2、導入自定義jar

     (1)創建字符串截取方法

 1 package com.example.Controller;
 2 
 3 public class TestJar {
 4     public  String doAppend(String mobile){
 5         String newmobile = "";
 6         newmobile = mobile.substring(0,3);
 7         return newmobile;
 8     }
 9 
10 }
View Code

(2)設置要導出的jar文件:File->project Settings->Artifacts,點擊添加jar

(3)導出jar:選擇build->build Artifacts即可導出

(4)把jar放入lib目錄,即可在jmeter中引入:

import com.example.Controller.*;
TestJar testJar = new TestJar();
String newmobile =testJar.doAppend("123456789");
vars.put("newmobile",newmobile);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM