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').textusername = 'user@compay.com'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 = UserBehaviortasks = [UserBehavior ]min_wait = 1000max_wait = 3000