- How Unit Tests Help Developers
- How Unit Tests Provide Overall Value
- Getting Started with Unit Testing
How Unit Tests Provide Overall Value
Aside from their immediate value to developers, as previously discussed, unit tests also provide value to the overall testing process:
- Unit tests create a test harness that can be leveraged for other types of testing.
- Unit tests can reduce the overall scope (coverage analysis and risk analysis) of other types of testing.
- Good unit tests remove the necessity for in-depth domain testing and in-depth boundary value analysis.
Creating a Test Harness
I mentioned earlier that unit tests and unit test harnesses can be leveraged elsewhere. Here's are some examples:
- Unit tests can be repurposed to address risks that may not have been envisioned when the tests were written.
- Unit tests can be used as a starting point for APIs used for test automation. They can be used to seed a suite of automated tests.
- Logs developed for unit testing can be leveraged throughout the test lifecycle.
- Test data that's developed or identified can be leveraged throughout the test effort.
All of these uses potentially lower the cost of testing throughout the project.
Reducing Scope for Other Types of Testing
Unit tests can reduce the overall scope (coverage analysis and risk analysis) of other types of testing. For example, system tests can be designed by reviewing the existing unit tests—in some cases, tapping into interfaces that developers had written for their own tests—and can focus on efforts that developers didn't address. System testers should take advantage of unit tests and design their own tests to mitigate risks not already addressed by the unit tests. For example, if you're concerned with code coverage, as many teams are (we won't go into the validity of those concerns), you can run your unit tests using a code-coverage tool and then develop system tests to exercise the code that hasn't already been executed. If you have concerns about specific high-risk features, such as integration with a third-party web service, you can develop system tests that complement the testing already performed at the unit level, instead of duplicating that testing.
Reducing the Necessity for Other Processes
Good unit tests remove the necessity for in-depth domain testing and in-depth boundary value analysis. I stole these two concepts from the mind of Cem Kaner. As a tester, I find them extremely valuable. With the exception of a quick sampling to verify that the right testing was done at the unit level, domain testing or testing at the boundaries for individual components might be omitted entirely, or at the very least drastically reduced. These classes of testing might still be needed at the application's system level, but the trivial cases could be executed up front during unit testing.
This seems to be an excellent place for developers and testers to collaborate. Many developers could benefit from a better understanding of domain and boundary value analysis, but because it's typically outside of their direct focus (get the code working), they may not be aware of these techniques. Testers can help by supplying this knowledge and/or generating the data for the tests. Specialized tools help to facilitate these discussions and activities.