Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does karate gating support Java DSL ? #2533

Closed
fingerdancer opened this issue Mar 13, 2024 · 2 comments
Closed

Does karate gating support Java DSL ? #2533

fingerdancer opened this issue Mar 13, 2024 · 2 comments

Comments

@fingerdancer
Copy link

fingerdancer commented Mar 13, 2024

we can run gatling test according to this wiki https://karatelabs.github.io/karate/karate-gatling/
The below is an Scala example on your doc. As we know, gatling also support Java DSL, so how to use Java DSL to do same thing ?
I tried a lot of ways but no one work. could you help me ?

import com.intuit.karate.gatling.PreDef._
import io.gatling.core.Predef._
import scala.concurrent.duration._

class CatsSimulation extends Simulation {

val protocol = karateProtocol(
"/cats/{id}" -> Nil,
"/cats" -> pauseFor("get" -> 15, "post" -> 25)
)

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

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

}

@f-delahaye
Copy link
Contributor

f-delahaye commented Mar 13, 2024

Please take a look at this example

Note that the name resolver may now be set in a more fluent way with:

    KarateProtocolBuilder protocol = karateProtocol(
      uri("/cats/{id}").nil(),
      uri("/cats").pauseFor(method("get", 15), method("post", 25)
    )).nameResolver((req, ctx) -> req.getHeader("karate-name"));

@ptrthomas I guess the documentation will be regenerated at some point?

@ptrthomas
Copy link
Member

closing as duplicate of #2168

@f-delahaye yes - the process we follow is that we only publish docs when we release final. until then it will be in develop: https://github.com/karatelabs/karate/tree/develop/karate-gatling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants