我有一个带有一组测试用例(@task)的蝗虫文件。是否有任何CLI选项可用,以便我可以解析蝗虫文件并从中获取测试用例或标记?从https://github.com/locustio/locust/blob/master/examples/basic.py中考虑下面的示例代码 这里有一个测试用例page404(),由@task确定
from locust import HttpUser, TaskSet, task, between
def index(l):
l.client.get("/")
def stats(l):
l.client.get("/stats/requests")
class UserTasks(TaskSet):
# one can specify tasks like this
tasks = [index, stats]
# but it might be convenient to use the @task decorator
@task
def page404(self):
self.client.get("/does_not_exist")
class WebsiteUser(HttpUser):
"""
User class that does requests to the locust web server running on localhost
"""
host = "http://127.0.0.1:8089"
wait_time = between(2, 5)
tasks = [UserTasks]
我使用类似的方法来操纵任务权重,不知道是否有帮助:
TaskSet下的tasks param是一个加权任务列表,例如,如果我有两个任务,一个权重为2,另一个权重为3,那么它将是
所以我将其转换为set以查找唯一的任务
您可以使用
locust -l
列出用户类,但是没有内置的方法来列出单个任务相关问题 更多 >
编程相关推荐