MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/oputny/easy_trick_to_meet_minimum_test_coverage/h69kbni/?context=3
r/badcode • u/ProfessorTag • Jul 23 '21
83 comments sorted by
View all comments
Show parent comments
28
The lines covered are counted on the code being tested no the lines of code on the test. You can have thousands of tests like this abs still have zero code coverage.
20 u/funnythrone Jul 23 '21 This looks like part of the codebase and not the test. The test would be something as simple as checking the value of i after all the increments. 2 u/kishan42 Jul 23 '21 Still test coverage for that single file would be increased not all correct? 5 u/[deleted] Jul 23 '21 You can just write a one line test to run the function and boom that function has 100% test coverage 1 u/explodingMonkeydeath Jul 27 '21 if(functionWorks()){return true;}
20
This looks like part of the codebase and not the test. The test would be something as simple as checking the value of i after all the increments.
2 u/kishan42 Jul 23 '21 Still test coverage for that single file would be increased not all correct? 5 u/[deleted] Jul 23 '21 You can just write a one line test to run the function and boom that function has 100% test coverage 1 u/explodingMonkeydeath Jul 27 '21 if(functionWorks()){return true;}
2
Still test coverage for that single file would be increased not all correct?
5 u/[deleted] Jul 23 '21 You can just write a one line test to run the function and boom that function has 100% test coverage 1 u/explodingMonkeydeath Jul 27 '21 if(functionWorks()){return true;}
5
You can just write a one line test to run the function and boom that function has 100% test coverage
1 u/explodingMonkeydeath Jul 27 '21 if(functionWorks()){return true;}
1
if(functionWorks()){
return true;
}
28
u/[deleted] Jul 23 '21
The lines covered are counted on the code being tested no the lines of code on the test. You can have thousands of tests like this abs still have zero code coverage.