2017-08-08 178 views
-1

我在JMeter中创建了一个简单的测试,我希望使用Maven运行它。我的pom.xml看起来象下面这样:无法执行目标com.lazerycode.jmeter:jmeter-maven-plugin:1.9.0:jmeter

<?xml version="1.0" encoding="utf-8"?> 
<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/maven-v4_0_0.xsd"> 

    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.epg</groupId> 
    <artifactId>jmeter-maven</artifactId> 
    <version>0.1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 
    <name>JMeter Maven</name> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>com.lazerycode.jmeter</groupId> 
       <artifactId>jmeter-maven-plugin</artifactId> 
       <version>1.9.0</version> 
       <executions> 
        <execution> 
         <id>jmeter-tests</id> 
         <phase>verify</phase> 
         <goals> 
          <goal>jmeter</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <resultsFileNameDateFormat>yyyyMMddHHmmss</resultsFileNameDateFormat> 
        <resultsFileFormat>xml</resultsFileFormat> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

,当我执行命令MVN安装我得到:

[info] Executing test: Sample Test.jmx 
[info] Completed Test: Sample Test.jmx 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 2.811 s 
[INFO] Finished at: 2017-08-08T16:21:23+02:00 
[INFO] Final Memory: 16M/245M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal com.lazerycode.jmeter:jmeter-maven-plugin:1.9.0:jmeter (jmeter-tests) on project jmeter-maven: c:\...\target\jmeter\results\20170808162123-Sample Test.jtl (The system cannot find the file specified) -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.lazerycode.jmeter:jmeter-maven-plugin:1.9.0:jmeter (jmeter-tests) on project jmeter-maven: c:\...\target\jmeter\results\20170808162123-Sample Test.jtl (The system cannot find the file specified) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146) 
     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) 
     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81) 
     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 
     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) 
     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309) 
     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194) 
     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107) 
     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993) 
     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345) 
     at org.apache.maven.cli.MavenCli.main(MavenCli.java:191) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 
Caused by: org.apache.maven.plugin.MojoExecutionException: c:\...\target\jmeter\results\20170808162123-Sample Test.jtl (The system cannot find the file specified) 
     at com.lazerycode.jmeter.JMeterMojo.parseTestResults(JMeterMojo.java:75) 
     at com.lazerycode.jmeter.JMeterMojo.execute(JMeterMojo.java:54) 
     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) 
     ... 20 more 
[ERROR] 
[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/MojoExecutionException 

看来,测试中执行,但由于某种原因,报告未创建。当我执行maven调用的相同命令时(jmeter -n -tc:... \ src \ test \ jmeter \ Sample Test.jmx -lc:... \ target \ jmeter \ results \ 20170808162635-Sample Test.jtl - dc:... \ target \ jmeter -jc:... \ target \ jmeter \ logs \ Sample Test.jmx.log)一切正常。一些想法?每JMeter Maven Plugin releases page

+0

通过JMeter的,Maven的插件的变化版本1.9.0,从2.1.0到解决 – user3568916

回答

0

由于

ResultsFileFormat在2.0.0

不工作这听起来像在JMeter的Maven插件本身,所以我相信你需要你的jmeter-maven-plugin版本升级到2.1的错误。 0或更高

<groupId>com.lazerycode.jmeter</groupId> 
<artifactId>jmeter-maven-plugin</artifactId> 
<version>2.1.0</version> 

确保您尝试之前调用mvn clean至少一次在设置要使用的新插件版本后运行verify阶段。

请参阅Five Ways To Launch a JMeter Test without Using the JMeter GUI文章以获取有关运行无头JMeter测试的不同方式的更多信息。

0

使用这个插件,将工作

<plugins> 
     <plugin> 
      <groupId>com.lazerycode.jmeter</groupId> 
      <artifactId>jmeter-maven-plugin</artifactId> 
      <version>2.1.0</version> 
      <configuration> 
       <testResultsTimestamp>false</testResultsTimestamp> 
      </configuration> 
      <executions> 
       <execution> 
        <configuration> 
        <testFilesDirectory>src/test/jmeter/</testFilesDirectory> 
        </configuration> 
        <id>jmeter-tests</id> 
        <phase>verify</phase> 
        <goals> 
        <goal>jmeter</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin>  
</plugins> 
相关问题