什么是压力测试
软件测试中:压力测试(Stress Test),也称为强度测试、负载测试。压力测试是模拟实际应用的软硬件环境及用户使用过程的系统负荷,长时间或超大负荷地运行测试软件,来测试被测系统的性能、可靠性、稳定性等。
常用的压力测试软件有:LoadRunner、Apache JMeter、NeoLoad、WebLOAD、Loadster、Load impact、CloudTest、Loadstorm、阿里云 PTS 等等,本文介绍的是使用 Apache JMeter 来进行压力测试。
创建线程组
右击 “Test Plan”,选择 “Add” > “Threads(users)” > “Thread Group”

添加取样器
右击 “Thread Group”,选择 “Add” > “Sampler” > “HTTP Request”

添加监听器
右击 “Thread Group”,选择 “Add” > “Listener” > “View Results Tree”

运行测试

生成测试报告
点击 “Tools” > “Generate HTML report” ,配置后参数后点击 “Generate report” 即可生成报告。

查看测试报告

比 JMeter 更好的选择
可以发现,JMeter 的测试流程配置相对繁琐。那么,是否有更加简单快捷的工具呢?我们强烈推荐 Apifox,使用非常方便,谁用谁知道。在 Apifox 中,首先新建一个接口,然后在自动化测试中导入该接口,点击运行,无需进行像 JMeter 中那样繁琐的配置,让复杂的流程变得简单易行。
新建接口

导入用例

运行测试

导出测试报告

想要全面提升 API 开发与测试效率,就用 Apifox。
免费使用:https://apifox.com/