Datasheet
6
Chapter 1: Preliminary Concerns
for the bug and time yourself again. In most cases, you’ll find that it only takes a few minutes to write a
test for the functionality and now your argument to your manager can be, “If I was permitted to spend
X amount of time creating a test, the customer would have never encountered this bug.” Most managers
will pay more attention to your requests if you have data to back up your reasons for wanting to do
something.
If you continue on the path of creating tests for your system, over time you will form a comprehensive
set of test cases. These test cases can then be executed during the development of your system, allowing
you to catch regression bugs earlier in the process. By having the tests catch these bugs, you will save
time and money in terms of re-testing the application but also in maintaining the system in production.
Only Junior Developers Should Create Tests
This claim is very far from the truth. It’s important for junior developers to write tests along with
senior developers. This claim is often an excuse for a manager to stick a junior developer on a project
just to create a bunch of test plans. However, the test plans and automated testing a junior developer
creates is often useless, because of a lack of training and guidance. It’s important for senior develop-
ers to work closely with junior developers to teach them what makes good tests. Testing is easy; good
testing is hard. It’s difficult to learn how to write good tests and create test plans from books; books
help with the concepts, but nothing matches sitting down and pair programming with an experi-
enced developer for the day.
If you are the senior developer and you notice this, take it upon yourself to help educate the junior
developer. Ask the manager if you can be responsible for a portion of the tests and help educate the
junior developer about the process. In the long run it will make your job easier having multiple people
on a team that can perform the task well.
If you are the junior developer, your career is ultimately your responsibility. You should speak to the
manager and request that a senior developer work with you for a portion of the tests. If the manager
disagrees, take it upon yourself to get the training you need to perform the task. Start with reading as
much about testing as you can, then try going to a local user group. Local user groups often have “hack
nights,” where they get together and write code, allowing you to learn with your peers.
Tests Cannot Be Created for Legacy Code
Testing legacy code is often more difficult, but it’s not impossible. Often, legacy code has not been
architected in a way that allows unit tests to be created, but in most scenarios functional or acceptance
tests can be created for them. During the past few years, many patterns have emerged that make test-
ing legacy code much easier. In the testing world, a code base that contains no tests is oftentimes
referred to as legacy code. This means that if you’re not writing tests as you write your code, all you
are doing is simply creating legacy code from day one.
This myth is generally just another excuse for managers that are uneducated about testing patterns.
It’s a great idea to write tests for legacy code. Oftentimes the developer who wrote the code is not
around to maintain it anymore and creating a test suite for the application will help a new developer
learn about the app and give other developers a safety net if they need to make changes in the
future.
96640c01.indd 6 9/25/09 7:18:28 AM