Why Unit Testing is Essential to 99.99 Software

[fa icon="user"] Patrick Emmons [fa icon="calendar"]  Feb 21, 2017 9:46:13 AM

Test HarnessWe're all under intense pressure to deliver applications fast. Agile development plus DevOps speed up the process for getting from code complete to code deployed, sometimes deploying code multiple times a day. The time available for an in-depth QA process is extremely limited.

When development teams focus on unit testing, quality is automatically built in to the development process. But the point isn't to reach 100 percent code coverage. Instead, get your team focused on testing the functionality that matters. Technology can provide support, but you'll only get to 99.99 software if your people and processes emphasize testing.

Here are 4 ways unit testing helps DevOps efforts reach maximum effect.

1. Testable Code vs. Fast Code

If your development team only feels pressure to deliver code fast, they'll focus on cranking out code and throwing it into production after just a minimal sanity check. You need to rethink your software development team's core values, so developers ask "how will I prove that this code actually works?" instead of "how fast can I get this code done?"

"Always code unit test as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."

With that change, developers start thinking about how they'll test code before they even start writing it. They need to design the software to be testable, not just to be runnable.

2. Testing Supports Teamwork

Creating testable code improves your code base and your teamwork. Code is meant to be used and reused. When developers deliver code that's been thoroughly unit tested, they support the next developer who works with that code. When code changes make a unit test fail, the developer knows there was some underlying assumption that their changes broke.

In the absence of unit tests to identify potential broken assumptions, developers would be checking in code that they are completely unaware is going to create more bugs instead of resolving them.

3. Lean Processes Lean Left

The most expensive place to find a bug is in production. Traditional testing approaches require writing code and handing it to QA to be tested. Buggy code cycles back and forth between Development and QA until quality levels are met.

There's no time for this in an agile, DevOps world. The choices are either to accept that you'll have bugs in production or to move bugs to the left, streamlining the process so developers find bugs before moving to staging.

4. Unit Test Automation Encourages Buy-In

Get developers to buy into this new emphasis by using tools to automate running regression tests. Developers need to run tests to verify specific changes, but running tests at the push of a button means that code will be thoroughly tested before moving forward in the release pipeline.

Since code units, whether called modules, functions, methods, procedures, subroutines or something else, form the basis of all released applications, automating unit tests verify that the core functionality of a component works as intended. This doesn't mean there can't be a logic error, or they can't be combined in ways that don't do what the business needs, but it does mean the building blocks are strong.

Soon, you can start to work in a more object-oriented way. By knowing the underlying building blocks are correct, you can focus on how you combine them to provide business functionality. Ultimately, that's why I believe so passionately in unit testing: the agile and DevOps approach isn't just about being fast, it's about being right. Emphasizing unit testing helps you "write code right" fast.


Newsletter Subscription

Stay Connected

DragonSpears Background

Solutions for a Wide Range of Industries

It can be done.

Learn More