天天看点

Locust(二)提高篇:关联,检查点,集合点

Locust加强篇(关联、检查点、集合点)

1、关联:

通常在业务流程

在这里插入代码片
           
from lxml import etree
from locust import TaskSet, task, HttpUser
class UserBehavior(TaskSet):
    @staticmethod地方地方
    def get_session(html):地方在这里插入代码片
        tree = etree.HTML(html)
        return tree.xpath("//div[@class='btnbox']/input[@name='session']/@value")[0] \
    @task(10)
    def test_login(self):
        html = self.client.get('/login').text
        username = '[email protected]'
        password = '123456'
        session = self.get_session(html)
        payload = { 'username': username, 'password': password, 'session': session }
        self.client.post('/login', data=payload)

class WebsiteUser(HttpUser):
    host = 'http://debugtalk.com'
    # task_set = UserBehavior
    tasks = [UserBehavior ]
    min_wait = 1000
    max_wait = 3000