DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Testing Java and Spring Applications With Kotlin: Low-Risk to Adoption
  • Does 100% Code Coverage Mean Tested?
  • How We Know What We Know
  • How to Interpret the Number of Spring ApplicationContexts in Integration Tests

Trending

  • Designing Memory Architecture for Stateful AI Agents: Short-Term Context and Long-Term Persistence
  • Agentic Test Creation: From Plain-Language Requirements to End-to-End Test Cases
  • MySQL Instant DDL: Metadata Locks, Waiting Writers, and Query Pileups
  • Deploying Small Language Models on Sovereign Cloud

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. Why Should You Get Rid of Flaky Tests?

Why Should You Get Rid of Flaky Tests?

Flaky tests, or unreliable or intermittent tests, can be detrimental to CI/CD optimization in several ways. Understand how to investigate to identify them.

By 
Mathieu Poissard
·
Nov. 08, 23 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
2.2K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Amidst the quest for automation and speed, a common obstacle emerges flaky tests. These seemingly innocent but troublesome tests can undermine the entire CI/CD optimization process.

To understand the nuisance of flaky tests, it's like having a roommate you can more or less count on. When you ask him for a hand, you never know how he'll handle your request. He may or may not pay the rent, and the same goes for chores. When you get home from work, your last yogurt may be waiting for you, or it may be digesting in his belly. That's what we call an unreliable roommate. Despite identical rules, conditions, and environments, he can make random decisions.

In fact, a flaky test is just the same. Under identical conditions, a flaky test will either pass or fail. A sort of Russian roulette.

In this article, we will dive into the concept of flaky tests, understand their implications, and explore why they are a nuisance.

What Are Flaky Tests?

Flaky tests, also known as unreliable or intermittent tests, are automated tests that exhibit inconsistent behavior.

These tests are characterized by their ability to produce both passing and failing results for the same codebase without any modifications. In simpler terms, running a flaky test multiple times can yield different outcomes, leading to inconsistent feedback regarding the stability and correctness of the system.

The Nuisance of Flaky Tests

Flaky tests can be detrimental to CI/CD optimization in several ways:

False Positives

Flaky tests can generate false positives, reporting failures when no actual defects exist. This can create unnecessary delays and frustration for developers, who have to investigate and fix non-existent issues, leading to wasted time and effort.

False Negatives

Conversely, flaky tests can also produce false negatives, where actual defects go undetected. When tests sporadically pass, potential issues can slip through the cracks, jeopardizing the quality of the software being delivered.

Unreliable Feedback

The primary purpose of automated tests is to provide reliable feedback on the stability and quality of the codebase. Flaky tests undermine this objective, making it difficult to distinguish between genuine failures and transient issues, eroding developers' trust in the test suite.

Decreased Productivity

Flaky tests hinder the efficiency of the development process. Developers spend precious time investigating and re-running tests to identify and reproduce failures, detracting them from focusing on crucial tasks like implementing new features or fixing genuine bugs.

Impaired Confidence

Flaky tests erode the confidence of both developers and stakeholders. Developers become skeptical of the test results, and stakeholders may lose faith in the reliability of the software being produced. This lack of confidence can have far-reaching consequences, affecting team morale and the overall success of the project.

How Can I Get Rid of Them?

Flaky tests are a real nuisance, and their impact is often underestimated. This problem, if not properly dealt with, will be dragged along like a ball and chain by the developers on your team. And the consequences can be dire:

  • Velocity at half-mast,
  • Vulnerable code base,
  • Loss of trust and consideration among developers...

Suffice it to say, it doesn't look good! Faced with this situation, it's time to adopt a proactive stance and look for concrete solutions. 

Test suite optimization Testing

Published at DZone with permission of Mathieu Poissard. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Testing Java and Spring Applications With Kotlin: Low-Risk to Adoption
  • Does 100% Code Coverage Mean Tested?
  • How We Know What We Know
  • How to Interpret the Number of Spring ApplicationContexts in Integration Tests

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook