[英]How do i run the functions randomly in jython script?
class TestRunner:
def __call__(self):
user1()
user2()
user3()
user4()
How do I execute the users randomly in jython, to run in grinder tool? 如何在jython中随机执行用户以在grinder工具中运行?
Store the functions in a list (without calling them), then use random.shuffle
: 将函数存储在列表中(不调用它们),然后使用random.shuffle
:
import random
class TestRunner:
def __call__(self):
users = [user1, user2, user3, user4]
random.shuffle(users)
for user in users:
user()
I don't know jython, but if you want a random choice, this should work 我不知道jython,但是如果您想随机选择,这应该可以
import random
class TestRunner:
def __call__(self):
func = random.choice([user1, user2, user3, user3])
func()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.