class TestRunner:
def __call__(self):
user1()
user2()
user3()
user4()
如何在jython中随机执行用户,在grinder工具中运行?
答案 0 :(得分:6)
将函数存储在列表中(不调用它们),然后使用random.shuffle
:
import random
class TestRunner:
def __call__(self):
users = [user1, user2, user3, user4]
random.shuffle(users)
for user in users:
user()
答案 1 :(得分:4)
我不知道jython,但是如果你想随机选择,这应该可行
import random
class TestRunner:
def __call__(self):
func = random.choice([user1, user2, user3, user3])
func()