尝试使用一种简洁的扩展方法来运行 gatling 3.0.2,我之前已经在 gatling 2.2.x 中多次使用过该方法
implicit class Extensions(val scenario: ScenarioBuilder) extends AnyVal {
def injectDefaults: PopulationBuilder =
scenario.inject(
rampUsersPerSec(RAMP_USER_PER_SEC) to LOAD_FACTOR during (RAMP_UP_TIME seconds),
constantUsersPerSec(LOAD_FACTOR) during (DURATION seconds)
)
}
但它不再编译,失败并显示:
could not find implicit value for evidence parameter of type
io.gatling.core.controller.inject.InjectionProfileFactory[Product with Serializable with io.gatling.core.controller.inject.open.OpenInjectionStep]
scenario.inject(
有人知道为什么吗?
我自己找到了解决方案,缺少一些隐式导入。这是完整的代码示例:
import io.gatling.core.Predef.{constantUsersPerSec, rampUsersPerSec,_}
import io.gatling.core.structure.{PopulationBuilder, ScenarioBuilder}
import scala.concurrent.duration._
object Config {
val LOAD_FACTOR: Double = 50
var RAMP_UP_TIME: Int = 10
val RAMP_USER_PER_SEC = 0.1
implicit class Extensions(val scenario: ScenarioBuilder) {
def injectDefaults: PopulationBuilder =
scenario.inject(
rampUsersPerSec(RAMP_USER_PER_SEC) to LOAD_FACTOR during (RAMP_UP_TIME seconds),
constantUsersPerSec(LOAD_FACTOR) during (DURATION seconds)
)
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)