金喜正规买球

开源API测试工具LoadUI Pro最佳实践:从Maven运行负载测试

翻译|使用教程|编辑:莫成敏|2020-01-13 15:07:41.930|阅读 296 次

概述:如果在开发环境中使用Maven,则可以在构建中包含LoadUI测试。为此,您可以命令Maven下载并在项目中使用ReadyAPI Maven插件。

# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>

LoadUI Pro,业界最好的开源API测试工具。通过一个可视化、拖拽式的界面,LoadUI允许您实时、交互式地创建、配置和重分配负载测试。在单一测试环境下,LoadUI提供完整的测试覆盖,支持所有标准的协议和技术。它功能强大,能从任意数量的本地和远程机器生成可扩展、大容量的工作负载。

ReadyAPI是API测试工具的集成套件,其中包括:SoapUI Pro (功能测试)、LoadUI Pro (性能测试)、ServiceV Pro (服务虚拟化)等产品。

点击下载LoadUI Pro正式版


如果在开发环境中使用Maven,则可以在构建中包含LoadUI测试。为此,您可以命令Maven下载并在项目中使用ReadyAPI Maven插件。

要求

要从Maven运行LoadUI测试,您需要在要运行Maven构建的计算机上具有以下内容:

  • 一个Pom.xml文件,其中引用了ReadyAPI Maven插件
  • ReadyAPI
  • ReadyAPI项目文件

您不需要专门为运行负载测试而配置环境,Maven将处理所有必需的依赖项。

Pom文件

Maven从pom.xml文件中读取有关构建的详细信息。您需要对其进行配置,以从Maven存储库获取ReadyAPI插件,并将负载测试添加到构建生命周期的测试阶段。

您可以在下面找到示例Maven配置。如果您已经拥有自己的配置,则将必要的元素复制到其中。

运行负载测试

要启动负载测试,请使用pom.xml文件所在文件夹中的Maven test命令。 此命令将运行负载测试并为其生成报告。 例如:

C:/Work/MvnSample> mvn test

如果您的测试使用Maven SureFire插件来创建报告,请改用site命令。

C:/Work/MvnSample> mvn site

样本Maven负载测试

以下是运行Baseline-load-test-project.xml项目的pom.xml示例文件。您可以在文件夹中找到该项目。要使用示例:

  • (可选)从项目启动虚拟服务。这一步不是必须的,但是具有正在运行的虚拟服务将提供有意义的结果。
  • 创建一个新的pom.xml文件并将示例代码复制到该文件。确保指定与ReadyAPI版本相同的版本。
  • Baseline-load-test-project.xml项目文件放在pom.xml文件所在的文件夹中。
  • 通过使用上述mvn site命令运行Maven构建。

您可以通过删除未使用元素的注释并输入参数来指定负载测试的其他属性。

如果您已经拥有pom.xml文件,则将其复制到该文件中以在构建中包括负载测试。

<project xmlns="//maven.apache.org/POM/4.0.0" xmlns:xsi="//www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="//maven.apache.org/POM/4.0.0 //maven.apache.org/maven-v4_0_0.xsd">    <modelVersion>4.0.0</modelVersion>    <groupId>com.mycompany.app</groupId>  &nbsp; <;artifactId>my-app</artifactId>    <version>1.0</version>        <!--Add the SmartBear ReadyAPI plugin repository.-->     <!--Maven will download the plugin from the specified URL.-->    <pluginRepositories>    &nbsp;  &lt;pluginRepository>          <id>SmartBearPluginRepository</id>  &nbsp;   &nbsp;   <url>http://smartbearsoftware.com/repository/maven2</url>      &nbsp;</pluginRepository>    </pluginRepositories>    <build>   &nbsp;   <plugins>          <plugin>             <!--Plugin groupID used to uniquely identify the project with the plugin.-->             <groupId>com.smartbear</groupId>   ;          <!--Plugin artifactId used to find the plugin in the project.-->     ;        <artifactId>ready-api-maven-plugin</artifactId>             <!--Specifies your ReadyAPI version. Maven will use the appropriate plugin version.-->   &nbsp;         <!-- IMPORTANT: Must be the same as your ReadyAPI version.-->      &nbsp;      ;<version>1.6.1</version>     &nbsp;      ; <executions>             ;   <execution>                   <!--Specifies the lifecycle phase to run load tests .-->             &nbsp;     <!--We recommend using the test phase.-->                   <phase&gt;test</phase>;                 &nbsp; <goals>                      <!--Do not change. Commands the Maven plugin to run a load test.-->                     &nbsp;<goal>loadtest</goal>                 &nbsp; </goals>            ;       <configuration>          &nbsp;           <!--Required. Specifies the path to the project to be executed.-->                      <projectFile>Baseline-load-test-project.xml</projectFile>                      <!--Required. Specifies the name of the load test to be run.--> &nbsp;            &nbsp;       <loadTest>Baseline Load Test (Geocoding)</loadTest>                      <!--Required for reports. Specifies the format of the report to be generated.-->                   &nbsp;  <!--Possible values: PDF, XLS, HTML, RTF, CSV, TXT and XML. --> <reportFormat>PDF</reportFormat>           ;           <!--Required for Maven Surefire reports. Must be true. -->                ;      <!--Commands LoadUI to generate JUnit-style reports.-->                &nbsp;     <junitReport>true</junitReport>                      <!--Required for> Maven Surefire reports. Must be as shown. -->                    &nbsp; <!--Specifies the folder to store reports in. -->       &nbsp;              <reports>${basedir}/target/surefire-reports</reports>     &nbsp;                <!-- ========= Additional elements ============= -->                  &nbsp; &nbsp; <!--If true, commands Maven to continue the test run even when an assertion triggers.-->                      <!--testFailIgnore>true<;/testFailIgnore-->      ;                <!--Specifies the number of virtual users to be simulated. -->       &nbsp;              <!--Has no effect if the "Per Scenario" load distribution is used.-->                 &nbsp;    <!--users></users-->                      &lt;!--Specifies existing statistics groups to be included in the report.-->    &nbsp;                 <!--statistics></statistics-->       ;               <!--Specifies limits for the test run. -->           &nbsp;        ;  <!--Syntax: <SECONDS>:<TARGETS>:<FAILURES> (for example, 60:0:200)-->         &nbsp;            <!--Project-defined time limits override this value.-->                      <!--limits></limits-->                      <!--Specifies the .CSV file to export the statistics group to. Syntax: <FileName>=<StatGroupName>-->                      <!--export></export-->                    &nbsp; <!--Specifies if the runner terminates requests running at the moment the test is stopped.-->                      <!--If true, ongoing requests will be canceled.-->                   ;   <!--Otherwise, the test will finish when all requests are completed.-->                      <!--If not specified, project properties are used.-->                      <!--abort></abort-->                      <!--Specifies if the load is simulated from the local computer.-->                    ;  <!--If true, the local computer is used. If false, configured agents are used.-->    &nbsp;                 <!--If not specified, project properties are used.-->            ;      &nbsp;   <!--local></local-->            &nbsp;         <!--Specifies the remote agents to be used for the test run. Syntax: <hostname[:port]>scenario</hostname[:port]>) -->                      <!--agents></agents-->     &nbsp;&nbsp;               <!--Sets the output folder for reports.-->  &nbsp;                   <!--outputFolder></outputFolder-->                   ;   <!--Specifies a settings file to be used.-->              &nbsp;       <!--settingsFile></settingsFile-->             ;         <!--Specifies a password for the encrypted settings file.-->       &nbsp;              <!--settingsPassword></settingsPassword-->          &nbsp;           <!--Specifies a password for the encrypted project file-->       &nbsp;              <!--projectPassword></projectPassword-->                   &nbsp;  <!--Specifies the value of a global property for the test run. Syntax: <variable>=<value>-->                &nbsp;     <!--globalProperties></globalProperties-->                      <!--Specifies the value of a project property for the test run. Syntax: <variable>=<value>-->        &nbsp;             <!--projectProperties></projectProperties-->            ;          <!--Provides access to ReadyAPI properties.--> &nbsp;                    <!--readyApiProperties></readyApiProperties-->                     &nbsp;<!--If true, ReadyAPI will not send usage statistics.-->   ;                   <!--optOutUsageStatistics></optOutUsageStatistics-->                      <!--Specifies the environment to be used in the test run.-->                      <!--environment></environment-->                      <!-- ========= /Additional elements ============= -->              &nbsp;    </configuration>                </execution>    &nbsp;   &nbsp;    </executions>  &nbsp;  &nbsp;    </plugin>    </build> </project> 
有关使用的插件的信息

此示例使用生成JUnit XML报告,并使用来提高测试稳定性。根据插件的更改,您可能需要更改pom.xml文件。

本文内容就是这样了,感兴趣的朋友可以继续关注我们网站了解更多产品资讯,您也可以下载LoadUI Pro试用版免费体验~


想要购买LoadUI Pro正版授权,或了解更多产品信息请点击




标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@fc6vip.cn

文章转载自:

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP