from locust Import TaskSet, task, Httplocust
Class Userbehavior (TaskSet):
def on_start (self): # when modulo When the user starts executing the Taskset class, the On_Start method is called
Self.index = 0
@task
def test_visit (self):
URL = self.locust.share_data[
Self.index] # takes self.locust.share_data< equals Websiteuser class definition Share_data > S Elf.index element
Self.index = (self.index + 1)% len (
self.locust.share_data) # Self.index value less than SE Lf.locust.share_data the length of the loop, generate <0.1.2.3.4, 0.1.2.3.4...>
r = self.client.get (URL) # Taskset class has a client property that returns Self.locust.client
Assert R.status_code = = $
Class Websiteuser (httplocust):
host = '/http Debugtalk.com '
Task_set = userbehavior
Share_data = ['/', '/archives/', '/about/', '/archives/2018/05/', '/a ' Rchives/2018/02/'] # shared data, loop traversal using
Min_wait = $
Max_wait = +
Python locust performance test: locust parameterized (list)---cycle through data, data can be reused