Code Coverage Percentage In Unit Testing
I have a class, having 3 methods(in python) . class MyClass: def A(self): ....... def B(self): ........ def C(self): ........ I have writte
Solution 1:
I got the answer myself :-)
Code coverage is all depends on which module or which files you are running the coverage for. Lets say if we run coverage for one file the way i had framed my question. Each line in each method will be accounted for code coverage.
Now as per my question i am covering only one method contain 20 lines. Other 2 methods have another 80 lines (total 100 lines in 3 methods). So if i ran coverage for my file. I would get code coverage of only 20%.
In python we can run (in pycharm terminal) like :coverage run -m py.test my_file.py To get the report run the command :coverage report -m py.test my_file.py
To run for entire module (in all packages) use : coverage run -m py.test and coverage report -m py.test
Post a Comment for "Code Coverage Percentage In Unit Testing"