smicyk / groovy-jmeter

A Groovy-based DSL for building and running JMeter test plans from command line and more.
Apache License 2.0
13 stars 1 forks source link

Common default cookie manager #70

Closed AntonioSun closed 2 years ago

AntonioSun commented 2 years ago

How to set a default cookie manager to all my requests?

    group(users: jmt_users, rampUp: jmt_ramp) {
      cookies()

This cookies() applies to all my requests under this group?

smicyk commented 2 years ago

Yes, I believe so. In this, it behaves the same as in JMeter GUI, If you put it under the group each thread from this group would have its own cookie storage area and each request should use it.

AntonioSun commented 2 years ago

Thanks while I have you, if I put https://github.com/smicyk/groovy-jmeter/wiki/reference#headers under the group, just like the cookies() above, with some default values, like Host, Origin, Referer, Connection, User-Agent etc,

Would each thread from this group and each request use such default values, together with the headers specified for themself?

smicyk commented 2 years ago

Yes.

AntonioSun commented 2 years ago

Great! Thanks for the confirmation!

AntonioSun commented 2 years ago

Hi @smicyk,

How about

      check_response {
        status() eq 200
      }

Does it has to go with each request, or I can place one at group level just like the cookies() above?

What if I want to check each response for keyword "Wrong" and mark the request fail if found. What's the best/simplest way to do that and how to do it please?

smicyk commented 2 years ago

If you put check_response on group level it will be added to all request (the assertion will check each request during execution). Please note, that you can't override assertion if you would like to have some different check on one particular request e.g.

plan {
   group {
       http 'GET /books'
       http 'GET /authors', {
           check_response {
               status() eq 404
           }
       }
       check_response {
           status() eq 200
       }
}

Then the /books will be asserted only with status eq 200 and /authors will be asserted with status eq 200 and status eq 404. So one of them will fail.