Gatling入門(二)IDEA+Maven編寫指令碼
1. 用scala-archetype-simple新建一個maven專案

IDEA中建立maven專案
2. 修改pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>demo.test</groupId>
<artifactId>gatling-performance</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>GatlingMaven</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.version>2.11.11</scala.version>
<gatling.version>2.1.7</gatling.version>
<gatling-plugin.version>2.1.7</gatling-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>${gatling.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<!-- Gatling Maven plugin that runs the load-simulation. -->
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling-plugin.version}</version>
<configuration>
<simulationClass>gatling.demo.HttpSimulation1</simulationClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
3. 編寫指令碼
package demo.test
import io.gatling.core.Predef._
import io.gatling.http.Predef._
/**
* Example Gatling load test that sends two HTTP requests to the same URL.
*/
class HttpSimulation1 extends Simulation {
val theHttpProtocolBuilder = http
.baseURL("http://computer-database.gatling.io")
val theScenarioBuilder = scenario("Scenario1")
.exec(
http("myRequest1").get("/")
)
setUp(
theScenarioBuilder.inject(atOnceUsers(1))
).protocols(theHttpProtocolBuilder)
}
4. 命令列執行 mvn gatling:execute

命令列執行
gatling的版本維持在2.1.7,我升級到2.2.4會報錯。
gatling2.2.4報錯
解決:需要在POM中,新增scala-reflect的依賴
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>${scala.version}</version>
</dependency>
另外,pom中如果使用scala-2.12.2版本,也會報錯。stackoverflow上說,是library的版本不匹配,一直不知道如何解決,留著坑待日後解決吧。。。
5. 檢視執行結果

執行結果
https://www.ivankrizsan.se/2016/03/27/creating-a-scala-project-with-maven-dependency-management-for-gatling-testing-in-intellij-idea/
http://stackoverflow.com/questions/41118777/scala-2-12-1-classnotfoundexception-productclass
相關文章
- scala入門之編寫scala指令碼指令碼
- 3.1 IDA Pro編寫IDC指令碼入門指令碼
- Shell指令碼入門:編寫格式與執行方式指令碼
- 油猴指令碼編寫指令碼
- 編寫git指令碼.shGit指令碼
- EA指令碼編寫要點指令碼
- 編寫shell指令碼的規範指令碼
- systemd 編寫服務管理指令碼指令碼
- 如何編寫高效的 Shell 指令碼指令碼
- 如何使用zx編寫shell指令碼指令碼
- rust學習二、入門之執行單個指令碼Rust指令碼
- 入門龍芯舊世界彙編指令
- nGrinder中快速編寫groovy指令碼01-指令碼結構指令碼
- Redis Lua指令碼完全入門Redis指令碼
- 編寫自己的Acunetix WVS漏洞指令碼指令碼
- 技能篇:shell教程及指令碼編寫指令碼
- 從零開始編寫指令碼引擎指令碼
- 專案啟動指令碼的編寫指令碼
- 字串編碼入門科普字串編碼
- iOS彙編入門教程(二)在Xcode工程中嵌入彙編程式碼iOSXCode
- shell 指令碼如何編寫-致初學者指令碼
- 如何用 JMeter 編寫效能測試指令碼?JMeter指令碼
- Linux編寫Bash指令碼的10個技巧Linux指令碼
- Linux之rsync同步分發指令碼編寫.Linux指令碼
- awk命令和指令碼的編寫啟蒙指令碼
- 如何編寫冪等的 Bash 指令碼?- Arslan指令碼
- linux裝置驅動編寫入門Linux
- python編寫圖片主色轉換指令碼Python指令碼
- DBA日常維護SQL指令碼_自己編寫的SQL指令碼
- linux編寫.sh指令碼並賦許可權Linux指令碼
- [20220330]編寫sql打補丁的指令碼.txtSQL指令碼
- 從0到1編寫一個指令碼引擎指令碼
- 簡單的 Shell 指令碼入門教程指令碼
- 三、日常運維指令碼編寫一些技巧運維指令碼
- 效能測試——壓測工具locust——指令碼初步編寫指令碼
- 利用 Powershell 編寫簡單的瀏覽器指令碼瀏覽器指令碼
- 如何編寫測試團隊通用的Jmeter指令碼JMeter指令碼
- 從0到1編寫一個JS指令碼引擎JS指令碼
- VBScript編寫Windows防止鎖屏指令碼程式詳解Windows指令碼