What makes automated tests/checks flakey?

This is what I was able to come up with:

  • Concurrency Issues: Tests affect each other when run in parallel, causing unpredictable outcomes, eg. two tests modify the same database record at the same time.
  • Environmental Differences: Variability across testing environments leads to inconsistent test results, for example when tests pass on a developer’s local machine but fail in the CI/CD pipeline due to different software versions.
  • Non-Deterministic Logic: Tests depend on elements that can change in value or behavior. Examples: Using the current date/time in tests, relying on random number generation.
  • External Dependencies: Tests rely on external systems that may not always behave the same way, eg. a test fails because a third-party API it depends on is temporarily unavailable.
  • Inadequate Test Isolation: Failure to keep tests independent of each other, sharing state or data. Example: One test’s outcome affects another because it doesn’t clean up created test data.
  • Resource Contention: Tests compete for limited system resources, causing delays or timeouts. Example: Parallel tests exceed the available database connections, causing some to fail.
  • Timing Issues: Tests make assumptions about execution time, which can vary, for example a test fails because it doesn’t wait long enough for a page to load in slower environments.
4 Likes