性能測試工具二之Gatling(二)

gatling-maven項目與Jenkins的集成
1.首先確保已經建立了一個maven項目(gatling),如上一篇博客點擊查看
2.此時還不能直接用maven命令運行該項目,因爲還未配置pom.xml文件,將裏面的pom文件內容替換爲以下內容(運行的測試用例換成自己的即可):

<?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>com.blazemeter.gatling</groupId>
    <artifactId>simple-gatling-tests-framework</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
            <dependency>
                <groupId>io.gatling.highcharts</groupId>
                <artifactId>gatling-charts-highcharts</artifactId>
                <version>2.3.1</version>
                <scope>test</scope>
            </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>io.gatling</groupId>
                <artifactId>gatling-maven-plugin</artifactId>
                <version>2.2.4</version>
                <configuration>
                    <configFolder>${project.basedir}/src/test/resources</configFolder>
                    <dataFolder>${project.basedir}/src/test/resources/data</dataFolder>
                    <resultsFolder>${project.basedir}/target/gatling/results</resultsFolder>
                    <bodiesFolder>${project.basedir}/src/test/resources/bodies</bodiesFolder>
                    <simulationsFolder>${project.basedir}/src/test/scala</simulationsFolder>
                    <runDescription>This-is-the-run-description</runDescription>
                    <!--運行多個個用例-->
                    <runMultipleSimulations>true</runMultipleSimulations>
                    <!--需要運行的用例(類似於白名單)-->
                    <includes>
                        <param>basic.TestPostMethod</param>
                        <!--<param>basic.TestPostMethod</param>-->
                    </includes>
                    <!--不需要運行的用例(類似於黑名單)-->
                    <excludes>
                        <param>basic.FirstTry</param>
                        <param>basic.MyFirstGatlingTest</param>
                    </excludes>
                    <!--運行多個個用例-->

                    <!--運行單個用例-->
                    <!--<simulationClass>basic.TestPostMethod</simulationClass>-->

                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

3.打開終端,進入到項目路徑(項目路徑爲H:\study\gatling-tests-framework\simple-gatling-tests-framework),執行mvn gatling:execute,出現以下結果說明成功了
這裏寫圖片描述
4.然後就是集成到Jenkins上了,首先已經成功安裝好Jenkins的環境,並且在Jenkins中安裝gatling的插件(具體安裝方法自行百度)
5.打開Jenkins,點擊新建任務輸入gatling-testing(隨便輸),選中“構建一個自由風格的軟件項目”,點擊確定
6.點擊高級配置項目路徑(不然之後運行完看不到報告的,因爲工作目錄與項目路徑不一致)
這裏寫圖片描述
這裏寫圖片描述
7.只需在構建中加入腳本,和構建後操作中選中track a gatling load simulation,點擊保存即可
這裏寫圖片描述
8.立即構建完成後會出現gatling圖標,點擊可以查看最近15次構建的響應時間
這裏寫圖片描述
9.點擊每一個點可查看詳細的報告
這裏寫圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章