By Your Own Standard

jtenner profile image jtenner ・2 min read

It is truly amazing how many people I talk to about testing their software now that I have written as-pect. I could talk with people for hours about how they only want to use software that works. In nearly every conversation, I talk their ears off, but more often I can see the gears turning in people's heads when we come to the topic of personal responsibility in software development.

We have all heard stories of nightmarish bug reports, 0-day exploits, and code reviews that could make anyone's stomach turn. People are really opinionated on this issue, and hate software that doesn't work. Period. Everyone can usually agree on this simple fact, and this isn't up for debate.

Chances are this is something that you personally care about too. Software that has a meaningful set of specifications and a functional test suite is by definition a better software implementation than one that shirks responsibility for its output.

So why is it that when I ask people about how they plan on testing their software, they give me excuses?

An example conversation might start with a question like: "What software are you making right now?"

The responses may vary, but inevitably I ask about performance and testing. This is where people who don't like their own personal behavior change their language.

They could say, "I'm not on that step yet."

They could say, "I don't need testing, my software is small."

Most of the time I hear: "I am not comfortable with testing yet."

It's infuriating to hear that people would choose this route, especially when they use the language of disgust and anger to describe themselves when they speak about this topic. The very same people who claim to want properly tested software will skip out on testing their own software because they think they know better. The worst part about all of these excuses is that none of what they say is true.

Testing is the first thing you do. Write your tests up front and then write the software. This can happen in little chunks or completely up front. The end result is the same.

How do I know this? People want to hold themselves accountable but they aren't brave enough to admit it.

Let me rephrase that. You want to hold yourself accountable but aren't brave enough to admit it.

The responsibility to start and complete testing of your software is yours, and yours alone. That's because nobody holds you to this standard, except for you. You are the primary unit of responsibility. Never make excuses for yourself. Install that testing framework. Start with that single unit test. Find an edge case and permanently make yourself responsible for the assertions it makes.

It's time to start rejecting the idea that anyone is above testing. If your software is more than 5 lines of code without a single test written, you've already skipped the very first step which is a unit test that you personally think is important. Not me.



Editor guide
jessekphillips profile image
Jesse Phillips

I think there is a case to be had for explanation programming where testing is postponed. I just don't know why people would choose language that do not have unittesting built in.

jtenner profile image
jtenner Author

Also, choosing JavaScript as your coding language means that you need a testing framework. This is because unit testing isn't built into the language. This is okay. A few utility functions like assert() get the job done.

 * The assert function verifies if a condition is truthy.
 * @param {boolean} condition - The condition that indicates if the
 * assertion passes.
 * @param {string} description - The message describing the assertion.
function assert(condition: boolean, description: string): void {
   if (!condition) throw new Error(description);

Another function I really like is the xor() function, because we can negate assertions using an exclusive or operation.

function xor(a: boolean, b: boolean): boolean {
  return (a && !b) || (!a && b);

And now, we can verify a contrapositive assertion.

const negated: boolean = true;
const condtion: boolean = /* some truthy assertion of application state. */;

// now perform the assertion
assert(xor(condition, negated), "This is a negated assertion.");

This example is obviously contrived, but a bunch of tiny little tools really help. You don't need a testing framework. You need responsibility.

jtenner profile image
jtenner Author

If you can find an example where you simply should delay testing, please show me. Every line of code is an opportunity to free yourself from the shackles of chaos, and you are the person who unlocks them.