Gatling 提供了可视化的接口录制功能,我们无须写任何代码,通过录制功能可以自动生成性能测试所需要的脚本。

上篇文件如何配置IntelliJ的开发环境,本文将谈谈如何使用录制功能。

  1. 在IntelliJ中选择Recorder文件右键运行,即可打开Gatling录制的界面,如果不是使用IntelliJ来开发,运行/bin/recorder.sh 命令也是可以启动录制界面的。

    设置完成后,点击start,开始录制。

  2. 在Firefox设置中,设置网络代理


  3. 使用类似PostMan的工具,模拟发送http请求

    如果使用的Https协议的话,需要添加例外


  4. Gatling客户端则会监听到接口请求,接口录制完成后,点击Stop & Save


  5. 在IntelliJ中可以看到录制完后自动生成的脚本

    由于录制过程中会有我们不需要的请求,可以在脚本中删除。

  6. 点击Engine脚本右键即可运行我们录制的脚本了。

    1
    2
    3
    4
    5
    6
    com.xiuxiuing.RecordedSimulation is the only simulation, executing it.
    Select simulation id (default is 'recordedsimulation'). Accepted characters are a-z, A-Z, 0-9, - and _

    Select run description (optional)

    Simulation com.xiuxiuing.RecordedSimulation started...

欢迎扫码关注公众号,更好的交流

欢迎扫码关注公众号,更好的交流