Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check that all functions have a test case?

Is there a standard method to check if all functions of all files that are included in a test have a testcase? So if I have script_1.py, script_2.py and script_3.py with corresponding test_script_1.py, test_script_2.py and test_script_3.py, how can I check that every function in script_x.py gets called at least ones by the test scripts?

I wrote the test functions in the format def test<Name_of_function>_<test_condition> so for example the function def sum(a, b) has test functions def testSum_valid_input and def testSum_invalid_input, so I could write a script that gets all the function names from the test scripts and compare that to the functions in the tested scripts, but I am hoping that there is already an easy way to do this.

like image 975
Niek de Klein Avatar asked Dec 06 '25 08:12

Niek de Klein


1 Answers

The best way is probably to use a coverage tool. It will tell you how much of your code is called at least one time by a test.

like image 55
neuro Avatar answered Dec 08 '25 20:12

neuro