Gradle与Gatling脚本集成
Gatling作为次时代的性能测试工具,由于其API简洁明了、性能出众,越来越受欢迎。但是运行Gatling脚本却有诸多不便,其提供的默认方式不是很方便。考虑到Gatling脚本本质上是Scala类,运行的时候还是使用的是java虚拟机,我们可以将其脚本的运行与Gradle结合起来。这样子就可以通过Gradle来运行Gatling脚本了。
废话少说,接下来就讲述下如何来进行配置。
创建一个标准的maven结构的工程目录,如下图所示。
conf目录存放Gatling的基本配置文件。 Gatling的脚本文件存放在src/test/scala/simulations包里面。可以自行在此包下对脚本文件再分类。
在build.gradle文件中引入scala插件。
1
|
|
然后引入有gatling库的maven repo。
1 2 3 4 5 6 |
|
再加入scala和gatling的依赖项。
1 2 3 4 |
|
把conf文件夹作为test的source文件。
1 2 3 4 5 6 7 |
|
创建一个名为gatling的task,目的是运行所有的gatling脚本。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
这是借助于Gatling的command line运行功能来实现的。具体参数指定官网上有,这里贴出原文。
Command Line Options # Gatling can be started with several options listed below:
- -nr (–no-reports): Runs simulation but does not generate reports
- -ro
(–reports-only ): Generates the reports for the simulation log file located in /results/ - -df
(–data-folder ): Uses as the folder where feeders are stored - -rf
(–results-folder ): Uses as the folder where results are stored - -bf
(–request-bodies-folder ): Uses as the folder where request bodies are stored - -sf
(–simulations-folder ): Uses as the folder where simulations are stored - -sbf
(–simulations-binaries-folder ): Uses as the folder where simulation binaries are stored - -s
(–simulation ): Uses as the name of the simulation to be run - -sd
(–simulation-description ): Uses as simulation description
我在github上创建了一个示例项目,请参见https://github.com/huangbowen521/gatling-gradle
出处:http://www.cnblogs.com/huang0925
黄博文的地盘
本文版权归本人和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述