zoukankan      html  css  js  c++  java
  • Jmeter-maven-plugin高级配置之选择测试脚本(转)

     

    在pom.xml文件中可以指定运行哪些jmx脚本。

    运行所有的测试脚本

    Jmeter默认运行${project.base.directory}/src/test/jmeter文件夹中的所有脚本,下面是示例。

        <project>
            [...]
                <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>
                        </plugin>
                    </plugins>
                </build>
            [...]
        </project>
    

    运行mvn verify即可。

    使用<testFilesIncluded>指定运行的脚本文件

    我们可以通过<testFilesIncluded>这个标签来手动指定jmx文件。样例如下:

        <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>
                     <configuration>
                          <testFilesIncluded>
                              <jMeterTestFile>test1.jmx</jMeterTestFile>
                              <jMeterTestFile>test2.jmx</jMeterTestFile>
                          </testFilesIncluded>
                     </configuration>
                </execution>
           </executions>
        </plugin> 
    

    当我们执行mvn verify时,只有${project.base.directory}/src/test/jmeter文件夹中的test1.jmx、test2.jmx会执行。

    在<testFilesIncluded>中使用正则表达式

    <testFilesIncluded>标签支持正则表达式,下面的示例,指定以foo开头的所有jmx文件。

                <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>
                            <configuration>
                                <testFilesIncluded>
                                    <jMeterTestFile>foo*.jmx</jMeterTestFile>
                                </testFilesIncluded>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
    

    使用<testFilesExcluded>标签反向指定jmx文件

    我们还可以使用排除法,来指定不要运行${project.base.directory}/src/test/jmeter文件夹中的文件。样例:

                <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>
                            <configuration>
                                <testFilesExcluded>
                                    <excludeJMeterTestFile>test3.jmx</excludeJMeterTestFile>
                                    <excludeJMeterTestFile>test4.jmx</excludeJMeterTestFile>
                                </testFilesExcluded>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
    

    当我们运行mvn verify时,${project.base.directory}/src/test/jmeter文件夹中除了test3.jmx和test4.jmx,其他的jmx文件都会执行。

    <testFilesExcluded>标签使用正则表达式

    反向指定jmx文件时,也可以使用正则表达式,样例:

                <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>
                            <configuration>
                                <testFilesExcluded>
                                    <excludeJMeterTestFile>*bar.jmx</excludeJMeterTestFile>
                                </testFilesExcluded>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
    

    运行时,以bar结束的jmx文件都会排除在外。

    <testFilesDirectory>标签指定jmx文件夹

    我们还可以自定义jmx文件的位置(默认是${project.base.directory}/src/test/jmeter)。

                <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>
                            <configuration>
                                <testFilesDirectory>/scratch/testfiles/</testFilesDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
  • 相关阅读:
    MS SQL SERVER导出表结构到Excel
    Ajax.ActionLink用法
    Layer弹出层关闭后刷新父页面
    Ajax.BeginForm提示不支持live属性或方法的错误
    BootStrap带样式打印
    利用JQuery jsonp实现Ajax跨域请求 .Net 的*.handler 和 WebService,返回json数据
    Bootstrap打印问题
    EF的表左连接方法Include和Join
    vs code的local history插件
    idea debug的drop frame,set watch和设置过滤条件
  • 原文地址:https://www.cnblogs.com/zhengah/p/5207071.html
Copyright © 2011-2022 走看看