Search code examples
javapythonjythongrinder

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?


Solution

  • Store the functions in a list (without calling them), then use random.shuffle:

    import random
    
    class TestRunner:
        def __call__(self):
            users = [user1, user2, user3, user4]
            random.shuffle(users)
            for user in users:
                user()