The Three Laws of Business

No freebies. No backsies. GTFO.

Archive for January 6th, 2009

You Nit Tests

without comments

People that have discovered unit tests for the first time act like little retarded Timmy in a candy store. Developers that have decided they deserve the title of “Senior” discover the joys of the percent-coverage metric. Surely full coverage will make up for them sucking at coding!

Like my Waffle House hash browns…

“We have 98% test coverage!” exclaimed the Senior Developer, with a smug expression on his face. His manager looked as proud as Timmy getting a participation certificate. I think they expected me to immediately kneel down and fellate them in awe, which I didn’t.

Taking a look over their test fixtures, it was pretty clear the tests had been written after the fact. Most of them were along the lines of “No Exception = Pass”. Some of them asserted some blatantly wrong results. Ninety-eight percent coverage and ninety-eight percent useless.

Hint: Writing your fucking tests to check the result is the same as what your first attempt outputted is going to ensure your results stay wrong.

Ensure_Adding_One_To_One_Results_In_Two()

Senior Dev, probably because he felt too important to do some useful work, had written some laughable Official Coding Standards. Part of this stressed the goal of “100% Test Coverage LOL” – and decreed that every goddamn property would be tested.

Here we are testing basic features of the CLR, using the CLR. Set the property, get the property, call Assert.Equals. Might as well stick in a few Adding One To One Results In Two tests while you are at it. If the platform is that retarded then it might well go like this:

3laws: Hey Timmy, can you remember the number 7 for me? Now can you press this big red exception button if the number you are remembering is different to 7?
Timmy: I like puppies!

For my sanity, please

Again, if you don’t know how to use a tool, put it down and walk away. Or at least take a step back and ask “Why am I doing this?”. Some pretentious fuckwad blogging about how your test coverage metric is linked directly to your epenis is not a good enough reason.

Still, I’m happy enough to get paid my consultancy rate to write unit tests for all my properties. Who am I to argue with the Official Standards if it makes it easier to do my job while drunk?

Written by 3laws

January 6, 2009 at 2:11 am

Posted in Uncategorized