1

I have a Selenium Class with a few methods:

class MyTest(unittest.TestCase):
    cls.USER = 'user'
    cls.PASSWORD = 'password'
    cls.browser = Chrome()
    cls.browser.get('http...')

    def test_1(self):
    .....

    def test_2(self):
    .....

    def test3(self):
    .....

As I add more methods, the one that is called first when I execute the entire MyTest class changes. Sometimes method test3 will get called first, but if I add another method, maybe test2 will be called first. How can I make sure test_1 is always called first?

1

1 Answer 1

1

According to documentation of unittest library :

Note that the order in which the various test cases will be run is determined by sorting the test function names with respect to the built-in ordering for strings

So you just need to define method names in alphabetical order to run them in order. Just change method name test3() to test_3().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.