简体   繁体   中英

How do you run multiple karate feature file in a gatling simulation?

How do you run multiple karate feature file in a gatling simulation?

The following is my code snippet for my gatling simulation:

class TestGatlingScalaSimulation extends Simulation {

  val log: Logger = LoggerFactory.getLogger(classOf[TestGatlingScalaSimulation])

  /*val environmentVars = System.getenv().asScala
  for ((k,v) <- environmentVars) println(s"key: $k, value: $v")*/

  val properties: mutable.Map[String, String] = System.getProperties.asScala
  //for ((k,v) <- properties) println(s"key: $k, value: $v")
  val activeUsers: Int = properties.getOrElse("SIM_ACTIVE_USERS", "10").asInstanceOf[String].toInt
  val rampUpPeriod: Int = properties.getOrElse("SIM_RAMP_UP_PERIOD", "10").asInstanceOf[String].toInt
  val karateFeatureFile: String = properties.getOrElse("SIM_FEATURE", "karate/example.feature")

  val protocol: KarateProtocol = karateProtocol()

  protocol.nameResolver = (req, ctx) => req.getHeader("karate-name")

  val create: ScenarioBuilder = scenario("create").exec(karateFeature(s"classpath:$karateFeatureFile"))
  log.info("Running simulation of feature [{}] with [{}] users ramped up in [{}]", karateFeatureFile, activeUsers.toString, rampUpPeriod.toString)
  setUp(
    create.inject(rampUsers(activeUsers) during (rampUpPeriod seconds)).protocols(protocol)
  )
}

I'm only able to run one feature file each time like this:

./gradlew -Pgatling_simulation=performance.TestGatlingScalaSimulation -DSIM_ACTIVE_USERS=100 -DSIM_RAMP
_UP_PERIOD=10 -DSIM_FEATURE="karate/flight/myfeature.feature" gatlingRun

This is described clearly in the docs: https://github.com/intuit/karate/tree/master/karate-gatling#usage

val create = scenario("create").exec(karateFeature("classpath:mock/cats-create.feature"))
val delete = scenario("delete").exec(karateFeature("classpath:mock/cats-delete.feature@name=delete"))

setUp(
  create.inject(rampUsers(10) during (5 seconds)).protocols(protocol),
  delete.inject(rampUsers(5) during (5 seconds)).protocols(protocol)
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM