【问题标题】:Failing maven-build when Gatling-test has too high fail-percentage当 Gatling-test 的失败百分比过高时,maven-build 失败
【发布时间】:2014-10-29 03:37:58
【问题描述】:

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

我当前的脚本是这样的:

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)
}

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

【问题讨论】:

    标签: scala maven maven-plugin gatling


    【解决方案1】:

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

    setUp(scn.inject( ... ))
        .protocols(httpProtocol)
        .assertions(
            global.successfulRequests.percent.greaterThan(90)
        )
    

    【讨论】:

      【解决方案2】:

      您必须使用Assertions API。

      【讨论】:

        猜你喜欢
        • 2017-10-28
        • 2020-03-26
        • 2010-11-26
        • 2016-11-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-11-21
        • 1970-01-01
        相关资源
        最近更新 更多