locust setting assertion method

https://blog.csdn.net/panyu881024/article/details/80146088

 


Here, too, to test the Baidu home page, for example.

 

 

 

catch_response = True: boolean, if set to True, to allow the request is marked as failed.

By client.get () method sends a request to the entire request Response, obtained by response.status_code request response HTTP status code. If it is not 200 by response.failure ( 'Failed!') Failed to print!

 

 

example:

def baidu_index (self):

  a=self.client.get('/', catch_response = True)

  if a.status_code == 201:
    a.success()
  else:
    a.failure("Got wrong response")

Guess you like

Origin www.cnblogs.com/kaibindirver/p/11772378.html