Using a unit testing tool as part of your software development process can save you time and money in the long run. This article discusses some of the pros and cons of unit testing, and then looks at the reasons for using a unit testing tool or framework.
The pros and cons of unit testing
The main benefit of unit testing is that it helps you to catch bugs earlier in the software development lifecycle. This ultimately saves you money because the later in the process a bug appears, the more expensive it is to fix. This is particularly true if the bug surfaces after the software has been released, especially if the software happens to be part of an embedded system.
Another benefit is that by testing modules as you go, rather than waiting until later, you build up confidence that the component parts of your system work correctly; and this reduces the overall level of risk associated with the project.
When you subsequently make changes to the system, the existing unit tests can be used to ensure that you have not inadvertently broken something (regression testing).
There is inevitably a cost associated with unit testing; each test has to be written and debugged, a script has to be prepared to build and run the tests (unless they are always run manually), and the test results have to be inspected. This cost must be balanced against the cost of bugs that go undetected.
The next section explains how a unit testing tool can reduce the cost of unit testing.
Why use a unit testing tool or framework?
You can write unit tests from scratch without using a unit testing tool or framework, but there are a number of points to consider:
Unit tests are code
Unit tests contain code and are just as likely to contain bugs as the code they are testing. This means they ought to be subject to the same quality checks; static analysis, coding standards conformance, code review, and testing.
This leads to the proverbial chicken and egg question: How do you test the test code?
Unit tests take time to write
Writing unit tests from scratch takes a significant amount of time. Quite often the unit test code is bigger than the code it is testing.
A consistent approach to writing unit tests
If you have several developers all writing unit tests from scratch you will probably find that they all have their own personal style. You could define a company-wide style for unit tests within your software process, but it is much easier to use a unit testing tool or a framework such as nUnit to promote a consistent style.
By using a unit testing tool or framework you reduce costs
You can create better unit tests more quickly because:
- There is less (or no) test code to write and debug
- You can concentrate on specifying test behaviour
- There is a consistent approach across all projects
Embunit reduces the time taken to create and maintain unit tests.
Why use a commercial unit testing tool?
When you buy a commercial unit testing tool like Embunit you get more than just the tool itself. You also get access to a wealth of knowledge, regular updates, and influence over new features.
Above all, you know that your questions will be answered quickly and your comments will be taken seriously.
Download Embunit today and evaluate it for 30 days using the built in evaluation key. The first time you run Embunit just click the button that says "I want to evaluate the software" in the license management dialog box.
Need longer to evaluate?
No problem, contact us and we will send you a new evaluation key.
Attention all students!
See the FAQ page to find out how to get Embunit for free.