Feb 03 2009

Unit Testing and building a Ford Focus…

Category: TestingPhil @ 10:35 pm

I was chatting with a friend today, and he told me a story that I could not believe. More interesting, was the fact that his story sounded exactly like my last post on Software Quality. His team was not on the same page, they each had different development philosophies and others used the existing environment to squash his proposal. So, what was his crazy idea? He proposed that the project use jUnit during the development process, and to add a line item to the project plan to include unit testing. He thought if unit testing was part of the project plan, the team would have a little more incentive to participate.

To his surprise and my dismay, the project manager said, “We are not building a Mercedes, we are building a Ford Focus, and doing unit testing is essentially unnecessary”. Oh my gosh, I about blew a gasket! I have been doing test driven development for so long, I would not even know how to write code without a unit test! What am am missing? Why wouldn’t a team want to create unit tests? How do they validate what they are building? Do they just use Loggers or print lines statements to generate output and then visually inspect the results?

This is one question that I have never been able to answer; why would a developer not want to create a structured unit test? Why do they prefer to add a “main” method to execute the code, rather than simply creating a jUnit test? I will not go into the benefits of using a continuous integration tool at this time, but just having a jUnit test that other developers could execute must be of some value. Right? Why would I want to continually inspect the output results of the class execution, when I could use assertions to actually validate the results of each test? The power, flexibility, speed, and maintenance of jUnit is not even comparable to value provided by a simple main method.

I personally believe that creating a unit test adds absolutely nothing to the overall cost of development. After all, the developer has to create something to validate the code, right? I have never seen a developer just sits down, write the code, and send it off to production. If code has to be executed to be validated, why not use jUnit? Throw in a tool like Eclipse, NetBeans, or IntelliJ, and it makes unit testing almost trivial. All the developer needs to do is click on a button and tool executes the unit test; these tools even have fancy windows to quickly show the result of each test, indicating success or failure.

There could be some potential downstream cost to supporting a unit test suite, but this cost has to be the same or less than than maintaining all of those of main methods. I also believe that the cost of supporting the unit test suite is offset by the total value provided by the suite. This value will be realized as the system evolves, allowing the team to refactor code, providing a validation framework for their changes.

Help me out here… Am I wasting my time building unit tests or have the other developers just not seen the light? Actually, I don’t think I am wasting my time, nor will I quit writing unit tests any time soon!

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png