首页 > 解决方案 > Gatling 设置顺序场景

问题描述

加特林文档状态

顺序场景 也可以使用 andThen 链接场景,以便在父场景中的所有用户终止后子场景开始。

setUp(
  parent.inject(injectionProfile)
    // child1 and child2 will start at the same time when last parent user will terminate
    .andThen(
      child1.inject(injectionProfile)
        // grandChild will start when last child1 user will terminate
        .andThen(grandChild.inject(injectionProfile)),
      child2.inject(injectionProfile)
    )
)

但下面的代码无法编译:

      setUp(
    scenario("A").inject(atOnceUsers(1))
      .andThen(scenario("B").inject(atOnceUsers(1)))
  )

编译错误:

     type mismatch;
 found   : io.gatling.core.structure.PopulationBuilder
 required: io.gatling.commons.validation.Validation[io.gatling.core.structure.PopulationBuilder] => ?
      .andThen(scenario("B").inject(atOnceUsers(1)))
                  

             ^

我正在使用加特林 3.3.1

标签: gatlingscala-gatling

解决方案


请检查该功能新功能列表中的里程碑字段:andThen在 Gatling 3.4.0 中引入,因此在 Gatling 3.3.1 中不可用。


推荐阅读