白季飞龙的个人主页

Locust大杂烩

1. 安装Locust

pip install locust

2. 编写测试脚本

mytest.py

from locust import HttpLocust, TaskSet, task


class WebsiteTasks(TaskSet):
    def on_start(self):
        pass

    @task(1)
    def index(self):
        self.client.get("/")

    @task(2)
    def about(self):
        self.client.get("/about")


class WebsiteUser(HttpLocust):
    task_set = WebsiteTasks
    host = "http://www.baidu.com"
    min_wait = 100
    max_wait = 100

说明:

3. 执行测试


漫漫路,莫论逍遥;潜心修,只为悟道