Selenium test priority in Flask

259 Views Asked by At

I have a use case in selenium in which the priority of test functions are important. I'm using LiveServerTestCase in flask for tests. In Java, there is a decorator @Test(priority=0) for defining test priorities. My question is what is the equivalent in Flask?

2

There are 2 best solutions below

1
Yousef Matinfard On BEST ANSWER

Test functions are executed according to their names(alphabetical order).

0
Satish Michael On

This may not answer your question as I have no knowledge nor experience with LiveServerTestCase, I am more of a pytest guy, and if you ever go down the pytest path, look up

https://github.com/ftobia/pytest-ordering/blob/develop/docs/source/index.rst

import pytest

@pytest.mark.order2
def test_foo():
    assert True

@pytest.mark.order1
def test_bar():
    assert True

Having said that, I looked at flask-testing documentation (I am assuming you are using this extension), it supports nose collector and test runner.

https://flask-testing.readthedocs.io/en/latest/#with-nose

And as per nose documentation, the tests run in the order they are defined in the test module file.

https://nose.readthedocs.io/en/latest/writing_tests.html#writing-tests

You can leverage the nose test runner. Again, my apologize this post does not help you.