简体   繁体   中英

using Gatling, how can the statusInfo in the response be checked?

When making an http request using Gatling, the response has the java method getStatusInfo() which returns and object of type StatusType which has a getReasonPhrase() which returns a String.
I'd like to get that reasonPhrase from the response.
How do I do that?
I tried the code below but it complains about the statusInfo:

  /**
    * give the user access 
    *
    * @param session current gatling session
    * @return the serialized body
    */
  def giveAccess(token: String, store: String, testUserUsername: String): ChainBuilder = {
    exec(http("Give Access")
      .post(MY_SERVICE_URI)
      .header(HttpHeaders.AUTHORIZATION, token)
      .header(MyHeaders.STORE, store)
      .headers(defaultHeaders)
      .headers(additionalHeaders)
      .body(StringBody(session => preparePayLoadForGiving(session, testUserUsername)))
      .check(statusInfo.reasonPhrase.is(session => "reason"))
    )
  } 

I think the fix is to replace:

statusInfo.reasonPhrase

by:

status.reasonPhrase

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