my intent in writing a test is to satisfy myself by the cheapest means possible that the code does exactly what i think it does. i stress that this is my intent. believe me, fifteen minutes on the internet will reveal to you a barrage of other possible intents.
surely, by now, it will be clear to you that i’m not an essentialist, but an extreme pragmatist w/strong existentialist leanings. my intent is to use the test to underpin my ability to offer what i call the geepaw guarantee.
the geepaw guarantee: it does exactly what i said it does, no less. it does it every time in every context i can imagine it encountering. i call it a guarantee. i mean, if it doesn’t do exactly what i said it did, call me. 24⁄7. i’m outta bed, i’m outta the bar, i’m on it.
notice, by the way, we’re already swimming deep into a lake of imperfection.
there are holes there. two come to mind immediately.
first, who says that what i said the code did is what you wanted the code to do? sure, the code does add two integers, just like i said it did. that doesn’t mean it wasn’t supposed to – from your view – multiply them.
second, while my imagination is indeed pretty fertile, it’s not sufficient to anticipate every conceivable context in the universe. the geepaw guarantee doesn’t extend to cover quantum effects or non-Turing architectures or opposite day.
those are real holes. i have to live with them. on another day, i’ll argue that you have to live with them, too, but not for now.
and i slid over a phrase i have to come back to now: “as cheaply as possible”.
that’s a key part of my intent, and it’s not ignorable or reducible. it’s dictated by what i’ve elsewhere called the money premise. i won’t elaborate much here, see “Five Underplayed Premises Of TDD”. the only reason the rest of the intent stands is because i want to make more features faster.
it does me no good to prove that what i said is what it does if the expense of doing that keeps me from adding more features. a non-TDDer will object, here, then why write tests at all? every test adds code, after all, so, like, math, dude.
it’s because no serious code is not dependent on other code.
on day 0 of your greenfield project, for a good half-hour or so, you are free of dependencies on your own code. after that, it’s self-dependency all the way down. being sure that i can depend on the code i wrote yesterday is a gigantic factor in being able to add more code today.
i can’t stress this enough. i want to know yesterday’s code works entirely so i can add today’s code as fast as possible. the money premise. so that’s my intent in writing a test. to satisfy myself as cheaply as possible that it does what i think it does.
since virtually all future conversation depends on that intent, i wish i had a name for it. i feel stupid and semi-corrupt when i propose calling it “the geepaw intent”. i could call it something that sounds more rigorous. but there’s no more compact form i know of than the statement itself. anything else is just a shorthand label.
i’m open to a better name. for now, i’ll call it the geepaw intent. in the follow-up musings, that’s the shorthand i’ll use, nless someone comes up with something better, and then i’ll make a fuss so readers can understand the switchover.
later, maybe tomorrow, i’ll take another step deeper into unravelling this automock thing. until then, geek on.