2017-08-08 179 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> 
相關問題