Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does test discovery mean as it relates to Python unit testing?

All search results return with "how-to" information rather than "what-it-is" information. I'm looking for a simple explanation of what this feature even is.

like image 338
Mr_Dave Avatar asked Feb 12 '23 04:02

Mr_Dave


1 Answers

Test discovering are the steps that are taken to find the tests in your codebase. This means you don't have to specify where your tests are but if the files contains the tests follow a certain location (filenames, directories, etc) then the testing framework can find them automatically.

When you run python -m unittest discover it'll search the current project directory for files with a filename that matches the pattern test*.py. When your tests are located in those files then you don't need to do anything else to run all your tests - just automatically discover all the tests, let them run and review the results.

The exact details of how test discovery works can vary from one testing framework to the next but the general idea is the same.

like image 83
Simeon Visser Avatar answered Feb 16 '23 04:02

Simeon Visser