Load Testing with Jmeter

JMeter is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions.

Main testing steps:

  • Double click jmeter.bat to open the Jmeter UI.
  • Open xxx.jmx file (test case file)
  • Click green "start" button in toolbar to start running testing.
Brief introduction to use Jmeter
  • HTTP Request Defaults element: define server name or IP and port number in it as follows.

  • HTTP Header Manager element: define some http header variables in it as follows  

  • User Defined Variables element: define some variables that will be used later in our http request.

  • CSV Data Set Config element: get token from csv file

  • Response Assertion element: use it to define how a http request is responded successfully.

  • Other elements: Please refer to Jmeter help document.

  • All elements can be added right-click menu "Add".

  • Test Result: We can check the test results in Summary Report element (result statistics) and View Results Tree element (success or failed).

 

  • All elements can be Enable/Disable via right-click menu to support run or skip run for specific elements.

 

  • How to set up heap for JVM: in Jmeter.bat, set HEAP=-Xms4g -Xmx4g to your wanted size.

  • It's better to test all APIs separately. (i.e. test one API one time)

  • If put json format in Raw Post Body, we need add Content-Type: application/json in HTTP Header Manager, otherwise, define application/json: "" in HTTP Header Manager.


Environment Requirment:

Test sending file in Jmeter:
  • Copy file content to Raw post body, uncheck Use multipart/form-data for post, only content in Raw Post Body will be saved to post stream.
  • Check Use multipart/form-data for POST, add files to "Add File with the Request", those files' content plus some additional header/tail information will be saved to post stream.
  • Use ${__FileToString(fileName,,fileString)} in BeanShell Sampler, put ${fileString} in Raw Post Body, or put ${__FileToString(fileName,,fileString)} in Raw Post Body directly.
  • Add BeanShell Sampler, in Script, add following scripts:
StringfileToString = SendFileUtility.ReadFileToString();

vars.put("FILE_CONTENT",fileToString);

Then put ${FILE_CONTENT}  in Raw Post Body.Copy jar file to jmeter\lib\ext

"SendFileUtility.ReadFileToString()" is implemented in Java.


  • Solutions above work well for text file, but may be don't work for binary file.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值