Blog

Is Your Source Code Ready For White Box Testing? by Garth Rose on Jan 06, 2017

The key to having a bug free, clean, smooth running software application, is to have virtually 100% of your source code fully white box tested. That means that every function, every method, and every line of business logic is addressed and fully tested.

Testable source code

One of the necessities of getting your source code fully white box tested is to first make sure your source code is actually testable. But, what does it mean to have source code that is testable? The only way to know if your source code is testable is answering the following question:

How long are your functions and methods?

A method or function that contains 300 lines of source code is harder to test than a method or function that is no more than 30 lines of code. If you’re really honest with yourself, you know this to be true. Let’s take a look at 7 of the benefits of having smaller functions and methods.

7 Benefits of smaller functions and methods:

  1. The complexity of the source code is easier to interpret and understand

  2. The syntax and structure of the source code is easier to read and consume

  3. The number of conditions or branches in the source code is easier to identify and grasp

  4. The business logic of the source code is easier to comprehend

  5. The source code is more adaptable to modifications and optimization

  6. The speed in finding and removing bugs is drastically increased

  7. The ability to maintain and update hundreds to thousands of regression tests is significantly simplified.

I could continue the list of benefits that comes from writing testable source code, but I think you get the idea.

Breaking down legacy application code is risky

Gaining all of these benefits would be great if it were possible to take legacy application source code and break it down. Unfortunately it is usually much too risky to take on such an endeavor. Just imagine the risks of taking a method containing 300 lines of source code and breaking into 10 methods each containing 30 lines of source code without those 10 new methods being fully white box tested. New bugs could easily enter into the source code and you could have chaos on your hands.

So, do you keep the code the way it is, too large, too complex and un-testable? If you don’t have the ability to white box test then you have no choice but to keep the code base old and outdated and hope it never breaks!

GenRocket to the rescue!

Fortunately, this is where GenRocket can help you. GenRocket’s solution for automated white box testing allows you to break down your source code into smaller, more testable functions and methods while also allowing you to fully white box test your modified and optimized source code at the same time, thus quickly and efficiently leading you down a path to a fully tested software application.

To learn more about the GenRocket automated white box testing solution, visit genrocket.com.