如何让Maven仅运行JMeter测试(没有其他生命周期) [英] How to have maven run just JMeter tests (no other life cycles)
问题描述
我们正在使用maven-jmeter-plugin
,并且我已经设置了jmeter配置文件.当我运行mvn -Pjmeter verify
时,各种Maven生命周期都会运行,但是它们都不需要.
We're using the maven-jmeter-plugin
and I've setup a jmeter profile. When I run mvn -Pjmeter verify
the various maven life cycles get run, but none of them need to.
如何仅运行JMeter测试?
How can I run just the JMeter tests?
<profile>
<id>jmeter</id>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>${jmeter.version}</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<testResultsTimestamp>false</testResultsTimestamp>
</configuration>
</plugin>
</plugins>
</build>
</profile>
推荐答案
不幸的是,插件的作者似乎未实现支持直接调用的MOJO,因此必须将插件用作生命周期执行的一部分—在<build>
部分中.
Unfortunately, it looks like the author of the plugin did not implement a MOJO that would support direct invocation, hence the plugin must be used as a part of lifecycle execution — within the <build>
section.
如果需要快速运行测试,可以尝试临时将<phase>
更改为较早的版本,例如validate
.不过,我敢肯定,这不是插件打算在其中运行的阶段,因此您不能永久更改此阶段.
If you need to run tests quickly, you could try to temporarily change the <phase>
to some earlier one, for example validate
. I'm sure, though, this is not the phase the plugin intended to be run in, so you can't change this permanently.
这篇关于如何让Maven仅运行JMeter测试(没有其他生命周期)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!