maven - 使用 Maven 执行 jmeter 测试时出现错误 "You must specify a valid lifecycle phase or a goal in the format"

标签 maven jmeter jmeter-maven-plugin

下面给出了用于运行 jmeter 文件的 POM 文件内容,但它在命令提示符下抛出错误,例如“您必须指定有效的生命周期阶段或格式中的目标”。请对此提供帮助

    <project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>jmeter-maven</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>jmeter-maven</name>
  <url>http://maven.apache.org</url>
  <build>
    <plugins>
      <plugin>
        <groupId>com.lazerycode.jmeter</groupId>
        <artifactId>jmeter-maven-plugin</artifactId>
        <version>1.4.1</version>
        <executions>
          <execution>
            <id>jmeter-tests</id>
            <phase>verify</phase>
            <goals>
              <goal>jmeter</goal>
            </goals>
            <configuration>
              <jMeterProcessJVMSettings>
                  <xms>1024</xms>
                  <xms>1024</xms>
                  <arguments>
                     <argument>-Xprof</argument>
                     <argument>-Xfuture</argument>
                  </arguments>
               </jMeterProcessJVMSettings>
               <propertiesUser>
                 <users>${users}</users>
             <rampUp>${rampUp}</rampUp>
                 <loop>${loopcount}</loop>
                 <url>${url}</url>
                 <suite>${suite}</suite>
               </propertiesUser>
               <testFilesIncluded>
                   <jMeterTestFile>testplans/Ecommersce.jmx</jMeterTestFile>
               </testFilesIncluded>
             </configuration>
           </execution>
         </executions>
        </plugin>
       </plugins>
      </build>

      <dependencies>
          <!-- https://mvnrepository.com/artifact/com.lazerycode.jmeter/jmeter-mavan-plugin -->
         <dependency>
              <groupId>com.lazerycode.jmeter</groupId>
              <artifactId>com.lazerycode.jmeter</artifactId>
              <version>2.1.0</version>
         </dependency>
      </dependencies>
   </project>

当我使用 Maven POM 运行 Jmeter 文件时,它在命令提示符下抛出错误,例如“您必须以格式指定有效的生命周期阶段或目标”

在命令窗口中出现以下错误
  C:\Desktop\jmeter\frameworkmaven>mvn verify -Dusers=1 DrampUp=1 Dloopcount=1 Durl=www.testing.com -Dsuite=framework
                [INFO] Scanning for projects...
                    [WARNING]
                    [WARNING] Some problems were encountered while building the effective model for com.example:jmeter-maven:jar:1.0-SNAPSHOT
                    [WARNING] The expression ${url} is deprecated. Please use ${project.url} instead.
                    [WARNING]
                    [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
                    [WARNING]
                    [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
                    [WARNING]
                    [INFO]
                    [INFO] ----------------------< com.example:jmeter-maven >----------------------
                    [INFO] Building jmeter-maven 1.0-SNAPSHOT
                    [INFO] --------------------------------[ jar ]---------------------------------
                    [INFO] ------------------------------------------------------------------------
                    [INFO] BUILD FAILURE
                    [INFO] ------------------------------------------------------------------------
                    [INFO] Total time: 0.192 s
                    [INFO] Finished at: 2018-11-01T21:16:26+05:30
                    [INFO] ------------------------------------------------------------------------


      [ERROR] Unknown lifecycle phase "DrampUp=1". You must specify a valid 

    lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

            [ERROR]
            [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
            [ERROR] Re-run Maven using the -X switch to enable full debug logging.
            [ERROR]
            [ERROR] For more information about the errors and possible solutions, please read the following articles:
            [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException

请对此提供帮助

最佳答案

根据 Jens 评论,您的命令行应该是:

mvn -Dusers=1 -DrampUp=1 -Dloopcount=1 -Durl=www.testing.com -Dsuite=framework clean verify



还:
  • 你应该使用 version 2.8.0jmeter-maven-plugin
  • 你应该删除这个无用的块
    <dependencies>
         <!-- https://mvnrepository.com/artifact/com.lazerycode.jmeter/jmeter-mavan-plugin -->
        <dependency>
          <groupId>com.lazerycode.jmeter</groupId>
          <artifactId>com.lazerycode.jmeter</artifactId>
          <version>2.1.0</version>
          </dependency>
       </dependencies>
    
  • 关于maven - 使用 Maven 执行 jmeter 测试时出现错误 "You must specify a valid lifecycle phase or a goal in the format",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53107975/

    相关文章:

    java - 无法使用 HTTP 脚本记录器在 Jmeter 2.10 中记录脚本

    java - 如何将 jmeter 3.2 与 jmeter-maven-plugin 一起使用?

    java - Lazerycode jmeter maven插件Java扩展下载排除依赖项

    jenkins - 需要分步指南在 Ubuntu 上执行 Jenkins(使用 Hudson 构建)中的 Jmeter 脚本

    java - 递归循环 Selenium Webdriver

    java - 无法使用 Maven 过滤应用程序上下文从 Eclipse 运行服务器

    java - Maven 程序集 : how package only imported/used dependencies for each execution

    java - 将当前项目的 target/classes/* 包含到 Maven 插件执行类路径中,以便使用 ASM 进行字节码检测

    android - 使用 Jmeter 进行移动应用程序测试

    testing - 负载测试复合 C1 CMS 控制台