R.A.Munna
R.A.Munna

Reputation: 1709

which file is executed first in pytest?

going through some tutorial about pytest. I have learned that

python -m pytest

this command executed the all file start with prefix test_ as well as function which files are located in same directory. But my question is which file is executed first if the files are test_app_id.py, test_sum.py, test_average.py, test_multiply.py.

Upvotes: 4

Views: 3451

Answers (1)

Soviut
Soviut

Reputation: 91515

The order tests run in shouldn't matter since tests, and your code, should be atomic. Meaning newer tests aren't affected by older tests; They're completely isolated from each other. This makes it possible to run test suites in parallel to speed up test running.

The tests will most likely run in alphanumeric order based on the file name. This would be further affected by the directory structure and how those directories are named as well. This may even be different depending on your operating system.

Rather than speculate, you should simply create your tests and run them, then see which order they ran in. If your test suite has a parallel or async option turned on, there's a good chance no two test runs will happen in the same order twice.

Upvotes: 6

Related Questions