简体   繁体   中英

Selenium test priority in Flask

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?

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.

测试函数根据其名称(字母顺序)执行。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM