我正在尝试使用Gatling加载测试Web服务.这是我的build.sbt
import io.gatling.sbt.GatlingPlugin
val gatlingVersion = "2.2.4"
val dependencies = Seq(
"io.gatling" % "gatling-core" % gatlingVersion,
"io.gatling" % "gatling-http" % gatlingVersion
)
lazy val project =
Project("gattling-tests", file("."))
.enablePlugins(GatlingPlugin)
.settings(
javaOptions in Gatling := overrideDefaultJavaOptions("-Xmx4G"),
scalaVersion := "2.12.1",
libraryDependencies ++= dependencies
)
Run Code Online (Sandbox Code Playgroud)
在tests文件夹下,我创建了一个扩展Simulation的类,它有我的场景和http请求.
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class ShieldAuthLoadTests extends Simulation {
val httpConf = http
.baseURL("http://localhost:8080/api/1/")
.acceptHeader("application/json")
.contentTypeHeader("json")
val login = http("Login")
.post("login")
.formParam("username", "foo")
.formParam("password", "bar")
.check(status.is(200), jsonPath("$..response.id").ofType[String].saveAs("id"))
val get = http("get")
.get("/api/api1")
.header("token1", "$id")
.check(status.is(200), jsonPath("$..response").exists)
val scn = scenario("scn")
.exec(login)
.pause(3)
.exec(get)
setUp(scn.inject(atOnceUsers(10)).protocols(httpConf))
}
Run Code Online (Sandbox Code Playgroud)
我的希望是,当我这样做时sbt gatling:test,它将进行加特林试验.但是当我运行sbt gatling:test它时,只是在没有运行测试的情况下取得成功.
该快速入门文档说$GATLING_HOME/bin/gatling.sh,但我没有gatling.sh,因为我想通过SBT测试.
小智 7
由于遇到类似的问题,文档有点不一致.
我始终立足于我的项目这只是可以肯定的.
无论如何,它看起来像你的依赖项的问题.尝试将它们更改为此...
val dependencies = Seq(
"io.gatling.highcharts" % "gatling-charts-highcharts" % "2.2.4" % "test,it",
"io.gatling" % "gatling-test-framework" % "2.2.4" % "test,it"
)
Run Code Online (Sandbox Code Playgroud)
或者看这里.
| 归档时间: |
|
| 查看次数: |
1451 次 |
| 最近记录: |