Complexities of Integration Testing

The third post in our journey to healthy test coverage in your legacy app leads us to integration testing. While unit tests provide us with a way to capture core user and module interchange commitment nothing does the job of capturing reality better than integration tests. Nullable fields and optional values can wreak havoc on your system, while data validation might occlude execution paths from ever being touched. Integration tests while slower and higher in complexity are at times the only way to validate the truth.
Here are some primary hurdles with integration tests:

  1. Data staging. In most cases, integration tests imply pushing data into your data layer and then executing the code that fetches and processes that data. Look for Factory frameworks to make it simpler.
  2. Idempotent. This becomes an absolutely essential point for this type of testing in particular. Integration tests retain state. That means you need to ensure that they can be executed in any order completely independent from each other. All necessary data needs to be staged and cleaned up upon the execution of every test.
  3. Performance. You are bound for slower performance so make the tests count. Parallelize test execution in CI, but only when they start taking way too long. Idempotent tests will save you here.

Leave a comment