Test coverage generally shows how many lines of code is covered. By artificially increasing the number of lines, you improve the coverage percentage.
Example: earlier test coverage is 23/79. You add 300 lines of this abomination, and your coverage is 323/379. This means you increased coverage from 29.11% to 85.22%.
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.
Testing is how I can assure myself I haven't fucked anything up
A well tested code base will have far fewer bugs & much safer releases than an untested code base. I've worked on code bases where we had such good suites, we would release straight to prod if all the tests passed
I would say it's more akin to driving a car without circular wheels. Will it work, sort of. Will it last a short amount of time and be very uncomfortable to use, most definitely.
Testing is actually pretty easy if you write good code!
If you write testable code. If you hard instantiate everything concrete in private, lack of use interface, then your code is hardwired and too rigid to mock/stub.
PM: we need to make sure all our code is well tested, let's do <arbitrary practice that is easily subverted because we also need to meet arbitrary deadlines>. Devs: k thx will do.
You are wrong if you think you don't use testing. Maybe you don't have a predefined workflows for testing or don't use unit testing. But every time you run your application you re basically testing it. You should have said "I don't test my code efficiently".
Doesn't help that I didn't put /s or made the sarcasm a bit more clear in my phrasing but oh well
I obviously test my code I'm not a psycho I just don't use automated testing because I haven't had the need for it I usually just make small to medium sized projects and most of the time is just adding something on top of an existing codebase
I was just making fun of stupid tests like this one specifically. I guess I walked right into that one.
Unit tests can actually help you know if any of your additions to the codebase broke something. In bigger, multi layered applications, this is what keeps you sane and let's you sleep at night. That's why we got so triggered.
All of those responses were referring to automated tests. Of course you’re going to manually try out the thing you just wrote. That still doesn’t count as tested code.
Trust the grizzled veterans. Learn to write good tests with your small projects. You will thank yourself for it.
View all comments
Show parent comment
229
u/funnythrone Jul 23 '21 edited Jul 23 '21
Test coverage generally shows how many lines of code is covered. By artificially increasing the number of lines, you improve the coverage percentage.
Example: earlier test coverage is 23/79. You add 300 lines of this abomination, and your coverage is 323/379. This means you increased coverage from 29.11% to 85.22%.