zoukankan      html  css  js  c++  java
  • jmeter+maven 的简单使用 记录(Windows环境)

    1.手动创建maven工程目录结构,maven对目录结构要求比较严格(pom.xml文件一定要放在根目录下)

       Maven

             --src

        --main

        --test

          --jmeter        

          --resources 

        --pom.xml

    我的main文件夹是个空文件夹

    jmeter文件夹下放置jmeter脚本、jmeter的配置文件

    resources文件夹下放置了报告的模板文件

                     

     2.pom.xml文件,这里有一个插件jmeter-maven-plugin

    <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.performance.test</groupId>
        <artifactId>PerformanceTest</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>
    
        <name>PerformanceTest</name>
        <url>http://maven.apache.org</url>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <jmeter.result.jtl.dir>${project.build.directory}jmeter
    esults</jmeter.result.jtl.dir>
            <jmeter.result.html.dir>${project.build.directory}jmeterhtml</jmeter.result.html.dir>
            <ReportName>TestReport</ReportName>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.uncommons</groupId>
                <artifactId>reportng</artifactId>
                <version>1.1.4</version>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.testng</groupId>
                        <artifactId>testng</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>3.8.1</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.1.0</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>xml-maven-plugin</artifactId>
                    <version>1.0-beta-3</version>
                    <executions>
                        <execution>
                            <phase>verify</phase>
                            <goals>
                                <goal>transform</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <transformationSets>
                            <transformationSet>
                                <dir>${jmeter.result.jtl.dir}</dir>
                                <stylesheet>src	est
    esourcesjmeter.results.shanhe.me.xsl</stylesheet>
                                <outputDir>${jmeter.result.html.dir}</outputDir>
                                <fileMappers>
                                    <fileMapper
                                        implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                        <targetExtension>html</targetExtension>
                                    </fileMapper>
                                </fileMappers>
                            </transformationSet>
                            <transformationSet>
                                <dir>${jmeter.result.jtl.dir}</dir>
                                <stylesheet>src	est
    esourcesjmeter.results.shanhe.me.xsl</stylesheet>
                                <outputDir>${jmeter.result.html.dir1}</outputDir>
                                <fileMappers>
                                    <fileMapper
                                        implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                        <targetExtension>html</targetExtension>
                                    </fileMapper>
                                </fileMappers>
                            </transformationSet>
                        </transformationSets>
                    </configuration>
                    <!-- using XSLT 2.0 -->
                     <dependencies>
                       <dependency>
                       <groupId>net.sf.saxon</groupId>
                       <artifactId>saxon</artifactId>
                       <version>8.7</version>
                       </dependency>
                   </dependencies>
                </plugin>
            </plugins>
        </build>
    </project>

    3.完成之后可以的命令提示符中通过执行maven命令来运行jmeter脚本

      先进入maven工程文件所在的目录

      执行 mvn verify命令,可以看到构建成功

      

    4.执行完成后可以在maven工程目录下看到多出一个文件夹 target ,这里面是执行结果信息

  • 相关阅读:
    hdu5728 PowMod
    CF1156E Special Segments of Permutation
    CF1182E Product Oriented Recurrence
    CF1082E Increasing Frequency
    CF623B Array GCD
    CF1168B Good Triple
    CF1175E Minimal Segment Cover
    php 正则
    windows 下安装composer
    windows apache "The requested operation has failed" 启动失败
  • 原文地址:https://www.cnblogs.com/kakaln/p/9821824.html
Copyright © 2011-2022 走看看