Editorials

Success with Testable Code

Aaron, from Data Specialists, finds the question, “Can my software be tested?” to be valuable in their product line. Aaron writes in response to the editorial "A Question to Improve Your Code":

I am in 100% agreement with you on the impact testing has had on the quality of the code I write. In fact a current college student interviewed me last week on my profession and what advice I’d have for someone getting into software development. One of the primary pieces of advice I gave was to try and find an employer that uses automated testing as a primary piece of their construction practices.

  1. The routines are smaller and easier to understand.
  2. A large suite of regression tests.
  3. By making code testable, I’ve been able to reuse pieces of SQL code for solutions that weren’t even envisioned at the time of creation. Without the tests, all those decisions may have been contained in a single script/stored procedure. When logic is in a large script/routine there is a tendency to duplicate parts of that code into a new script instead of pulling common pieces out into reusable chunks.
  4. Tests speed up the amount of time it takes to get my head back into a specific set of functionality. Depending on the toolset being used, you may have written those tests in a Cucumber-like style which provides user stories which can make things quicker to digest. I have found they also assist in relating features to other stakeholders.

How do you create SQL Unit Tests? Share your implementation here or by email to btaylor@sswug.org.

Cheers,

Ben