Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
AI

The AI Prompt That Finds Which Test Assertion Is Flaky

- 28.11.26 - ErcanOPAK

🤖 The AI Prompt That Finds Which Test Assertion Is Flaky

When a single test in a large suite fails intermittently in CI, the hard part usually isn’t spotting that the test is flaky – it’s figuring out which of the several assertions inside that one test body is the one actually producing a different result between runs, especially in an integration test with ten or more assertions back to back. A well-structured prompt handed the test’s full source plus a handful of real CI run logs, both passing and failing, can narrow a forty-line test down to the one comparison that’s nondeterministic, in far less time than adding print statements and waiting for the flake to reproduce again.

📋 The Prompt

You are reviewing a flaky integration test. I will give you:
1. The full source of the test method (including every assertion)
2. Logs from 3 CI runs where the test PASSED
3. Logs from 3 CI runs where the test FAILED

Your task:
- For each assertion in the test, determine whether its expected and
  actual values could plausibly differ between runs (timing, ordering,
  floating-point precision, environment-dependent state, uninitialized
  shared fixtures, etc.)
- Rank the assertions from most to least likely to be the actual source
  of the flake, with a one-sentence reason for each
- For the single most likely assertion, propose the smallest possible
  code change that would make its outcome deterministic
- Do NOT suggest simply adding a retry or increasing a timeout unless
  you can point to specific evidence in the logs that timing is the cause

[paste test source]
[paste passing run logs]
[paste failing run logs]

✅ Use It Well

  • Always include both passing AND failing log excerpts – a prompt given only the failure has to guess at the test’s normal behavior, while one with both can compare them directly and often spot the exact diverging value.
  • Ask explicitly for a ranked list rather than a single answer; a test with multiple borderline assertions benefits from seeing the full reasoning, because the actual flake is sometimes the second-ranked guess rather than the first.
  • Paste the real, unedited test source – trimming “irrelevant-looking” setup code is exactly how a shared fixture’s hidden state, the actual cause more often than not, gets accidentally removed from what the model can see.

🚨 Why This Is Dangerous

A ranked list of likely causes is a starting point for investigation, not a verdict – treating the model’s top guess as confirmed and shipping a fix without actually reproducing the flake under the proposed change can leave the real nondeterminism in place while everyone believes it’s solved.

The model doesn’t know which assertion is flaky any more than you do – what it’s actually good at is reading ten log lines faster than you can, and that’s the whole value of the prompt.

— AI Power User

Related posts:

AI Prompt: Plan the Perfect Road Trip with Hidden Gems and Time Optimization

AI Prompt: Plan the Perfect Road Trip with Hidden Gems and Time Optimization

The AI Prompt That Turns a Dependency Tree Into an Upgrade Order

The AI Prompt That Turns a Dependency Tree Into an Upgrade Order

The AI Prompt That Turns Your Recurring Subscriptions List Into a Clear Case for What to Cancel

The AI Prompt That Turns Your Recurring Subscriptions List Into a Clear Case for What to Cancel

Views: 11
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

C#: Fix a Static Lambda Still Capturing the Outer Instance
Asp.Net Core: Fix gRPC Deadlines Ignored by a Retry Policy

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 562 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com