当Gatling-test具有过高的失败百分比时,maven-build失败

Ets*_*tse 6 scala maven-plugin maven gatling

我试图通过Gatling进行简单的性能测试.我用maven来运行这个过程.为了在代码中的更改破坏我的gatling-tests时轻松获取,我希望maven-build失败.我已确保添加<failOnError>true</failOnError>我的pom.xml文件.

我目前的脚本是这样的:

class MySim extends Simulation {
    val httpProtocol = http.baseURL("http://localhost:8080")
    val scn = scenario("Test")
         .exec(http("request_1")
           .get("""/helloworld""")
           .check(status.is(200))
         )
    setUp(scn.inject(ramp(1 users) over (1 seconds))).protocols(httpProtocol)
}
Run Code Online (Sandbox Code Playgroud)

我使用maven(使用gatling-maven-plugin)运行构建,使用mvn clean gatling:execute它将永远成功.(即使服务器没有运行).我正在寻找一种方法来确保当gatling-test失败(或者失败百分比过高)时maven构建失败.

Ets*_*tse 8

所以我找到了一个解决方案:我所要做的就是使用我想要的标准向setUp添加断言.因此,如果成功率低于90%,则以下代码将失败maven-build.

setUp(scn.inject( ... ))
    .protocols(httpProtocol)
    .assertions(
        global.successfulRequests.percent.greaterThan(90)
    )
Run Code Online (Sandbox Code Playgroud)