2017-06-20 74 views
0

我想通過使用maven並希望報告性能結果來對jmeters junit採樣器執行負載測試。我用了10個線程與5 sec.here的緩升時期是我的POM文件使用maven執行jmeters junit採樣器

enter code here <properties> 
     <selenium.version>3.0.1</selenium.version>  
    </properties> 

    <dependencies> 

     <!-- https://mvnrepository.com/artifact/junit/junit --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId>   
      <scope>test</scope> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>${selenium.version}</version> 
     </dependency> 

    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>com.lazerycode.jmeter</groupId> 
       <artifactId>jmeter-maven-plugin</artifactId> 
       <version>2.2.0</version> 
       <executions> 
        <execution> 
         <id>jmeter-classes</id> 
         <goals> 
          <goal>jmeter</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <junitLibraries> 
         <artifact>com.lazerycode.junit:junit-test:1.0.0</artifact> 
         </junitLibraries> 
        <propertiesGlobal> 
         <threads>10</threads> 
         <rampup>5</rampup> 
        </propertiesGlobal> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

請幫助我,如果它是調用JMeter的JUnit的要求sampler.If沒有,請幫助我改正正確的方式。

也請幫助我如何報告性能結果(egreports)

感謝和問候

回答

0

由於每JMeter Maven Plugin文檔,你應該把依賴下<jmeterExtensions>標籤一樣的Adding additional libraries to the classpath章:

<?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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>jmeter-selenium-junit</groupId> 
    <artifactId>jmeter-selenium-junit-test</artifactId> 
    <version>1.0-SNAPSHOT</version> 

    <repositories> 
     <repository> 
      <id>your-junit-jar</id> 
      <name>your junit repo</name> 
      <url>file:/path/to/your-junit-jar.jar</url> 
     </repository> 
    </repositories> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>com.lazerycode.jmeter</groupId> 
       <artifactId>jmeter-maven-plugin</artifactId> 
       <version>2.2.0</version> 
       <executions> 
        <execution> 
         <id>jmeter-tests</id> 
         <goals> 
          <goal>jmeter</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <jmeterExtensions> 
         <artifact>org.seleniumhq.selenium:selenium-java:3.0.1</artifact> 
         <artifact>org.seleniumhq.selenium:selenium-firefox-driver:3.0.1</artifact> 
        </jmeterExtensions> 
        <junitLibraries> 
         <artifact>com.yourcompany.yourgroup:your-artifact:1.0-SNAPSHOT</artifact> 
        </junitLibraries> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

另請注意,有一個WebDriver Sampler JMeter Plugin whic h提供與Selenium的無縫JMeter集成,因此您不必每次都重新編譯Selenium代碼,並將其直接內聯到.jmx文件中。