gpt4 book ai didi

java - 仅通过直接调用运行 Jmeter 测试

转载 作者:行者123 更新时间:2023-12-01 18:42:50 24 4
gpt4 key购买 nike

我将 Jmeter 插件添加到我的项目中,现在它的负载测试与 Maven 构建一起运行。

  <!-- Jmeter  -->
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.9.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>deploy</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>

我希望通过运行以下命令来运行 Jmeter 测试:

mvn jmeter:jmeter -Pjmeter

我不希望它在执行任何 Maven 生命周期时运行,例如:

mvn install

由于测试是在 Restful API 中执行的,因此负载测试将在每次运行 Maven 生命周期时执行 POST 并在数据库中创建数据。

有人可以帮助我吗?

最佳答案

只需输入您的 JMeter Maven Plugin jmeter profile下的声明像:

<profiles>
<profile>
<id>jmeter</id>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<!-- Generate JMeter configuration -->
<execution>
<id>configuration</id>
<goals>
<goal>configure</goal>
</goals>
</execution>
<!-- Run JMeter tests -->
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
<!-- Fail build on errors in test -->
<execution>
<id>jmeter-check-results</id>
<goals>
<goal>results</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

这样,只有明确指定 jmeter 配置文件时,JMeter maven 插件才会执行

演示:

enter image description here

更多信息:

关于java - 仅通过直接调用运行 Jmeter 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59888408/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com