- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
Admin
...unless it is used via Reflection/Activator.CreateInstance()
Edit Admin
Did they have any tests which ensured that comments don't get executed and that write space separates keywords? No? See, it's not 100%!!
Admin
I hate to say this, but that codebase is still better covered than most parts of the codebase of the company where I work :D
Admin
A testing framework or library that would mark an entire class as covered based on the given test examples should be taken out back and shot. Twice.
Edit Admin
Ah yes I'm familiar with this pattern. 100% coverage is good, hell sometimes testing "basic" things isn't awful. But you have to know that testing is meant to test functionality, not behavior.
Admin
I don't understand how you would go about configure a testing framework to show 100% test coverage without any tests which test the code, even if you wanted to
Edit Admin
This ... might be the scariest manager story I have ever seen on this site.
If this manager believes this class of test is actually helping keep bugs at bay, and (shudder) teaching that to any green developers who find their way into his group, we are looking at a Typhoid Mary level of danger, spreading out to other shops as people leave this one.
Edit Admin
With that handy GAU-8 you keep in your back pocket.
Edit Admin
And this is exactly why mutation testing is so valuable. https://www.youtube.com/playlist?list=PLMrm16n64Bub8urB-bsyMyHiNPMLG7FAS is my playlist of versions of my presentation on it, in lengths from about 22 to 69 minutes, depending how in-depth you want to go.
Admin
I had a feeling something was up when I saw "100% test coverage". If they told me 80%, or 93%, it would sound good, but to get 100% you are either doing weird tests which barely touch the code but actually do nothing, as described, or everything is a slog.
A type of testing I'd like to see more is behavior testing, where you are testing the overall inputs and outputs to the program, running it through scenarios at a high if not top level. This makes the tests more durable to refactors, since you weren't testing every stupid class, which is what usually happens with unit testing.
Never got to that golden land myself, but a man can dream.
Edit Admin
When I read test coverage I always have to cringe.
Let's take this code as an easy example:
Now if we write a unit test and feed it 10 different values we end up with 100% test coverage; great right, bug free code?
Actually, no. Not at all in fact. We tested 10 combinations out of 2^65 possible once. Spitting in an ocean has more effect than this test, in fact spitting into the black hole at the center of the galaxy would have more effect.
So (unit) tests are useless? Yes, obviously, at least in the way a lot of people think of them (aka those that care about test coverage).
There is two awesome use cases where tests make sense:
Preventing bugs from happening again (so basically bug coverage).
Implementing a highly complex especially when certain not obvious acceptance criteria are required.
Force developers that start coding without having a clue what to do from actually think about where they want to go once (that's called test first, part of TTD).
While (1) is pretty much a no brainer and by far the most valuable. A bug fix without a test that makes sure that the bug never happens again is in my opinion not a bug fix, just a delay tactic. I think everyone has already been in projects where the same bug happens over and over again.
On the other hand (2) is pretty situational and it is more a guard rail for the developer (and future developers modifying the code) than something that will result in better code. It's a tool to avoid to fall when on uncertain ground.
The last one (3) is something that can be used to fix a bigger issue (the guy that writes code for a week and then announces it didn't out). If there's a dev on the team that doesn't know the road when starting coding then forcing code first will only patch the issue but not fix it. But sometimes there's no other way to deal with the situation, so it's better than nothing.
Edit Admin
Thought longs wrote ints. Oops. For 32 bit values it would be 2^33. But I think longs have a nice ring to it because that's when the black hole works out nicely.