2

Right Now I am trying to do performance testing of all my api's.I already created one feature file having different scenarios(every scenario having different tag).Now I want to do use assertions on mean ResponseTime with different scenarios different assertions.

val Performance1 = scenario("Performance1").exec(karateFeature("classpath:mock/Testing1.feature@Performance"))
val Performance2 = scenario("Performance2").exec(karateFeature("classpath:mock/Testing2.feature@v3ContentMeta"))

val v4SearchTest = scenario("SearchTest").
group("SearchTesting") { exec(karateFeature("classpath:mock/Testing1.feature@Performance"))
}

setUp(
  (Performance1.inject(rampUsers(10) over (5 seconds)).protocols(protocol)),
    Performance2.inject(rampUsers(10) over (5 seconds)).protocols(protocol)
  ).assertions(details("SearchTesting").responseTime.mean.lte(680))```
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
Gaurav Kinra
  • 183
  • 6
  • 12

1 Answers1

3

You can add Gatling assertions as Global asserts. This will perfectly work with Karate Gatling. This is a sample scenario which we tried

setUp(
    firstScenario.inject(
      nothingFor(5 seconds), // Pause for a given duration
      atOnceUsers(10), //Inject 10 Users at once
      constantUsersPerSec(10) during (20 seconds), // Induce 10 requests on every second and continues this process for 30 seconds
      rampUsers(10) over (10 seconds) // Linear Ramp up of the user
    ).protocols(protocol),

    secondScenario.inject(
      nothingFor(10 seconds), // Pause for a given duration
      atOnceUsers(20), // Inject 10 Users at once
      constantUsersPerSec(10) during (10 seconds), // Induce 10 requests on every second and continues this process for 40 seconds
    ).protocols(protocol),

    thirdScenario.inject(
      nothingFor(15 seconds), // Pause for a given duration
      rampUsers(20) over (1 minute) // Linear Ramp up of the user
    ).protocols(protocol),

    fourthScenario.inject(
      nothingFor(20 seconds), // Pause for a given duration
      constantUsersPerSec(10) during (20 seconds), // Induce 10 requests on every second and continues this process for 20 seconds
    ).protocols(protocol)

  ).assertions(
    global.responseTime.max.between(100, 5000),
    global.failedRequests.percent.is(0),
    global.successfulRequests.percent.gt(90)
  ).maxDuration(10 minutes) // Configuring the maximum duration of your simulation. It is useful when we need to bound the duration the simulation when we can’t predict it.

The global asserts will be displayed as a separate section in the Gatling reports. This is a useful feature of Karate Gatling. Test specific failures will also get displayed in the report of Karate Gatling. For example, if this is your scenario

Scenario: My First Sample Scenario
    Given url endpointUrl
    And header karate-name = 'Feature 1_Scenario3'
    When method get
    Then status 200

And if the status code is not responded as 200, this also gets recorded in the Karate Gatling reports.

Asserts in Gatling: https://gatling.io/docs/current/general/assertions/#scope

Sree
  • 331
  • 1
  • 4
  • 14
  • thanks @Sree but what I am trying to do is let say I have 5 different scenarios and I want to use assertions on every scenarios mean time.So instead of ```global``` what else I can use.Please suggest. – Gaurav Kinra Mar 14 '19 at 10:44
  • 1
    I have edited the answer above. Can you check the assertion section in Gatling? I hope you can do it using the mean: perform the assertion on the mean of the metric. – Sree Mar 14 '19 at 19:11
  • can you please give me an example how to use groups in gatling assertions because i am not able to do assertions on group level basis. – Gaurav Kinra Mar 26 '19 at 11:56