如何将 .Net 单元测试与 JMeter 集成

How to integrate .Net unit tests with JMeter

之前我使用 Visual Studio Load Test 为我的负载测试生成负载。我创建了由 VS 负载测试调用的 .Net 单元测试。现在 VS Load Test 已被 Microsoft 淘汰。我可以将现有的 .Net 代码与 JMeter 集成吗?

您不能将 .NET 代码与 JMeter 集成,因为根据 JMeter project main page

The Apache JMeter™ application 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.

如果您仍然可以执行 Web 测试,则可以通过 JMeter 的代理重播它们。

  1. 准备 JMeter 进行记录。最简单的方法是 JMeter Templates Feature

    • 从 JMeter 的主菜单中选择“文件 -> 模板 -> 记录”并单击 "Create"

    • 打开 HTTP(S) 测试脚本记录器并单击 "Start"

  2. 准备 Visual Studio 进行录制,在您的 Web Test Project properties 中将 JMeter 设置为代理:

  3. 运行 你的 Visual Studio 测试

  4. JMeter 将捕获请求并创建相关的 HTTP Request samplers under the Recording Controller

您可能仍需要手动执行 correlation/parameterization