Photo credit: https://www.flickr.com/photos/spacex/44451125454/
I have been doing more and more testing recently and I wanted to start capturing some of my thoughts on testing. An important topic is the differences between a unit test and an integration test. I feel like this is pretty straight forward, but is still worth clarifying, since I feel like it is done incorrectly way too often. My definition of each breaks down as follows:
Unit Tests:
Integration Tests:
Both unit and integration are focused on the internal quality of the application, whereas acceptance tests focus on the external, or business quality of the application.
Code Coverage
I feel very strongly that developers should focus on achieving >80% code coverage by unit tests only. Unit tests should target happy case logic as well as exception logic. With integration tests, it is not necessarily to target a high code coverage. Integration test coverage needs to cover integration points. For instance, write integration tests to ensure your Hibernate database mappings are wired correctly. Exceptions that could result from a integration failure should be defined behavior in the unit test, and expressed easily through fakes.
Summary
Your team should have a testing strategy that focuses on using both unit and integration tests, as both have a different focus and goal. If you have additional criteria to add to this discussion, please feel free to share it.
Share this: