Monday, December 28, 2009

Unit Testing 101 Guidelines Part 2

See also Unit Testing Guidelines Terminology, Part1, Part2, Part3, Part4

What is Integration Testing?

Integration tests test the coupling between much larger components of code compared to unit testing.  While unit testing is intended to test only one member within a class, an integration test is intended to test many classes all at once.  Hence the name “Integration Test”.  Often this means testing the integration between two components like two architectural layers or libraries.

Integration Tests are less frequently used than unit tests. Integration Tests should be stored in a different namespace, they sometimes have more overhead to run them and they may take longer to run.  They can be automated, but because they often require specially constructed environments to run and take time, they are not used in automated builds, gated check-ins or developer testing.  QA Testers would run integration test as part of acceptance testing and regression testing (possibly performance testing also).

A developer will run the unit tests many times through the course of his/her day to test for breakages, and they run quickly.  Integration tests are run less frequently and test far fewer use cases. They are merely intended to test the coupling not every possible or valid permutation of test data input.

For example: In an N-Tier system there may be a presentation layer, a business layer, and a services layer.  A common scenario would be to test some large feature in the business layer and mock out the services layer entirely using a real WCF service but all the services within the service layer are mocked.  This means that most if not all the components in the business layer being tested are real production objects.  Also the WCF communications is actually taking place over real end-points and bindings and actual production messages are being transmitted.  The service layer does host a real WCF service but the services within it are all mocked out to return hardcoded data or the like. In this example all components in the Business layer are being "Integration Tested".

No comments:

Post a Comment