Unit testing has been overlooked in application development too often and for too long, according to Roy Osherove,...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
author of the new book,The Art of Unit Testing. In a recent interview, however, he said there's a rekindled interest in unit testing in agile development organizations. That's a good thing, if testers are doing unit tests well.
Use of unit testing is increasing because agile emphasizes testing earlier in and throughout the development process. Also, Osherove noted, unit testing is just right for agile's short iteration releases that require finding and fixing bugs early.
Many application testing teams, particularly agile teams, are aware of what unit testing is, but Osherove's work in the field has shown him that people are performing the tests incorrectly. Osherove has authored several books on unit testing and writes about it on his blog, ISerializable. Heworks for Israel-based TypeMock, which develops testing tools.
Typically, unit tests should be run in the early stages of the software development lifecycle. They are designed to catch bugs in the infancy of the application when bugs are less costly to fix. But if unit tests are not executed correctly, bugs go through into production, Osherove said. This can cost a company thousands of dollars and sometimes more.
So, where exactly are teams failing and why? Well, according to Osherove, the failures are not entirely placed on an individual's shoulders but on the entire team, starting with the management chain of command. Many problems can often be attributed to miscommunication between development and management teams.
"There are numerous failure stories where unit testing was done wrong and, while many of them are anecdotal, you tend to hear them everywhere," Osherove said. "Many start with an agile team trying to build unit testing into their normal testing protocol under poor management backup. A lack of management leads to a lack of direction. There are also concerns with buy-off and unit testing of overly-large areas of code."
Over-reliance on automated testing tools is leading to project and/or iteration failures. Most automated testing tools have little or no focus on unit testing, Osherove explained. So, issues a properly performed unit test could have found slip through the cracks and enter the marketplace. This is why it is best to begin unit testing early on.
"In the past, if you weren't highly-educated in unit testing, there was a good chance you would write the unit test incorrectly. Since then, it has become a far more comprehensible testing choice, getting great results if the person writing and performing the test is competently equipped to do so," said Osherove.
Unfortunately, first-time unit test failures often deter would-be regular unit testers away from unit testing all together. "Those one time failures and should be looked at as a learning experience," Osherove said. "Unit testing should not be written-off. It is a great way to assure quality in your software and or application. If you invest in proper tooling, you will [likely] not experience a repeat of your prior failures."
The Art of Unit Testing was written to be a go-to for any agile or .Net software development team interested in unit testing, whether they are confused by it or have experienced failure and want to give unit testing a much deserved second chance. In his book, Osherove delves into how to use various vendor and open source tools for unit testing.
If your team has made an attempt with unit testing and failed and is still working to get a problematic application back in working order, then Osherove advised giving it a second try. Keep in mind that these tests are only useful when written by a competent tester/developer team. Otherwise you are running the risk of poor time management and employing testing that is both ineffective and unfocused.
Editor's note: SearchSoftwareQuality is offering four copies of The Art of Unit Testing to the first four testers who send in a short story about a time where you and/or your development team succeeded with unit testing or experienced failures with it and then succeeded in subsequent efforts. Send your stories to email@example.com.