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?

NewToJS
  • 2,011
  • 4
  • 35
  • 62
  • Possible duplicate of [Execution order on python unittest](https://stackoverflow.com/questions/16364433/execution-order-on-python-unittest) – Sraw Nov 05 '18 at 22:10

1 Answers1

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().

sayhan
  • 1,168
  • 1
  • 16
  • 22