如何让Maven仅运行JMeter测试(没有其他生命周期)

EGH*_*GHM 5 jmeter maven jmeter-plugins jmeter-maven-plugin

我们正在使用,maven-jmeter-plugin并且已经设置了jmeter配置文件。当我运行mvn -Pjmeter verify各种Maven生命周期时,它们都不需要运行。

如何仅运行JMeter测试?

<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>
Run Code Online (Sandbox Code Playgroud)

MaD*_*aDa 2

不幸的是,该插件的作者似乎没有实现支持直接调用的 MOJO,因此该插件必须在该部分中用作生命周期执行的一部分<build>

如果您需要快速运行测试,您可以尝试暂时将更改<phase>为较早的测试,例如validate. 不过,我确信这不是插件打算运行的阶段,因此您无法永久更改它。