fix-flaky-tests
यह क्या करती है
यह स्किल flaky automated tests की जाँच करती है, जो बिना code बदले कभी pass और कभी fail होते हैं, और उन्हें ठीक करती है। यह उन डेवलपर के लिए है जो अपने test suite को भरोसेमंद बनाना चाहते हैं।
कब इस्तेमाल करें
- ✓जब Tuist में कोई test flaky चिह्नित हो और आप उसे ठीक करवाना चाहें।
- ✓जब कई tests बेतरतीब fail हों और आप उनका आम कारण ढूँढना चाहें।
- ✓जब आप प्रोजेक्ट के सभी flaky tests खोजकर ठीक करना चाहें।
Skill का लिंक
https://github.com/tuist/tuist/blob/main/skills/skills/fix-flaky-tests/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरे प्रोजेक्ट के flaky tests ढूँढिए और जो सबसे ज़्यादा fail होता है उसे ठीक कीजिए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट हर flaky test की विश्वसनीयता और विफलता विवरण पढ़ता है, बताई गई पंक्ति पर उसका source पढ़ता है, flakiness का कारण बनाने वाला पैटर्न पहचानता है, उसे ठीक करता है, फिर पुष्टि के लिए test कई बार चलाता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Fix Flaky Tests
Quick Start
You'll typically receive a Tuist test case URL or identifier. Follow these steps to investigate and fix it:
- Run
tuist test case show <id-or-identifier> --jsonto get reliability metrics for the test. - Run
tuist test case run list Module/Suite/TestCase --flaky --jsonto see flaky run patterns. - Run
tuist test case run show <test-case-run-id> --jsonon failing flaky runs to get failure messages and file paths. - Read the test source at the reported path and line, identify the flaky pattern, and fix it.
- Verify by running the test multiple times to confirm it passes consistently.
If no specific test is provided, start with the Discovery section below.
Discovery
When no specific test case is provided, find all flaky tests in the project:
tuist test case list --flaky --json --page-size 50
This returns all test cases currently flagged as flaky. Key fields:
module.name/suite.name/name— the test identifieravg_duration— helps prioritize (fix fast unit tests first)is_quarantined— whether the test is already quarantined
Triage strategy:
- Group tests by suite — multiple flaky tests in the same suite often share a root cause.
- Check if failures share a
test_run_id— tests that all failed in the same run may have been killed by a process crash, not individual test bugs. - Look at failure messages to categorize: test logic bugs vs infrastructure issues (network errors, server 502s, conflicts on retry).
Investigation
1. Get test case metrics
You can pass either the UUID or the Module/Suite/TestCase identifier:
tuist test case show <id> --json
tuist test case show Module/Suite/TestCase --json
Key fields:
reliability_rate— percentage of successful runs (higher is better)flakiness_rate— percentage of runs marked flaky in the last 30 daystotal_runs/failed_runs— volume contextlast_status— current state
2. View flaky run history
tuist test case run list Module/Suite/TestCase --flaky --json
The identifier uses the format ModuleName/SuiteName/TestCaseName or ModuleName/TestCaseName when there is no suite. This returns only runs that were detected as flaky.
3. View full run history
tuist test case run list Module/Suite/TestCase --json --page-size 20
Look for patterns:
- Does it fail on specific branches?
- Does it fail only on CI (
is_ci: true) or also locally? - Are failures clustered around specific commits?
4. Get failure details
tuist test case run show <test-case-run-id> --json
Key fields:
failures[].message— the assertion or error messagefailures[].path— source file pathfailures[].line_number— exact line of failurefailures[].issue_type— type of issue (assertion_failure, etc.)repetitions— if present, shows retry behavior (pass/fail sequence)test_run_id— the broader test run this execution belongs tocrash_report— crash report data (present when the test runner crashed); containsexception_type,signal,exception_subtype, andtriggered_thread_frames
Code Analysis
- Open the file at
failures[0].pathand go tofailures[0].line_number. - Read the full test function and its setup/teardown.
- Identify which of the common flaky patterns below applies.
- Check if the test shares state with other tests in the same suite.
Common Flaky Patterns
Timing and async issues
- Missing waits: Test checks a result before an async operation completes. Fix: use
await, expectations with timeouts, or polling. - Race conditions: Multiple concurrent operations access shared state. Fix: synchronize access or use serial queues.
- Hardcoded timeouts:
sleep(1)or fixed delays that are too short on CI. Fix: use condition-based waits instead of fixed delays.
Shared state
- Test pollution: One test modifies global/static state that another test depends on. Fix: reset state in setUp/tearDown or use unique instances per test.
- Singleton contamination: Shared singletons carry state between tests. Fix: inject dependencies or reset singletons.
- File system leftovers: Tests leave files that affect subsequent runs. Fix: use temporary directories and clean up.
Environment dependencies
- Network calls: Tests hit real services that may be slow or unavailable. Fix: mock network calls.
- Date/time sensitivity: Tests depend on current time or tim
अक्सर पूछे जाने वाले सवाल
यह flaky tests कैसे ढूँढती है?
यह Tuist की test insights में flaky चिह्नित tests की सूची बनाती है।
अगर कोई test न दिया जाए तो?
यह प्रोजेक्ट में flaky tests खोजती है और उन्हें suite के हिसाब से समूहित करती है।
सुधार की पुष्टि कैसे होती है?
test को कई बार चलाकर जाँचा जाता है कि वह लगातार pass होता है।
जानकारी
लेखक का मूल विवरण
Fixes flaky tests by analyzing failure patterns from Tuist test insights, identifying root causes, and applying targeted corrections. Can be invoked with a specific test case URL (e.g. `https://tuist.dev/{account}/{project}/tests/test-cases/{id}`) or without arguments to discover and fix all flaky tests in the project.
repo: tuist/tuist
लोकप्रियता
- GitHub स्टार
- 5.9k
- रैंकिंग में स्थान
- #14544
- लाइसेंस
- —
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
analyze-selective-testing
5.9kयह आपके एजेंट को जाँचने देती है कि Xcode selective testing ने बिना बदले test targets को कितनी अच्छी तरह छोड़ा, और रनों के बीच छोड़ने में बदलाव क्यों हुआ।
compare-builds
5.9kयह आपके एजेंट को दो Xcode build runs की तुलना करने देती है, ताकि धीमे builds, cache उपयोग में बदलाव और नई समस्याएँ पता चलें।
compare-bundles
5.9kयह आपके एजेंट को दो app bundles की तुलना करने देती है, ताकि आकार में बदलाव, जुड़ी या हटी फ़ाइलें और platform के अंतर पता चलें।
compare-cache-runs
5.9kयह आपके एजेंट को दो cache runs की तुलना करने देती है, ताकि cache hit दरों में बदलाव पता चले और यह समझा जा सके कि cache क्यों अमान्य हुआ।
मिलती-जुलती skills
test-driven-development
311kयह आपके एजेंट को किसी भी फ़ीचर या सुधार से पहले पहले असफल होने वाला टेस्ट लिखना, उसे असफल होते देखना, फिर पास करने वाला सबसे छोटा कोड लिखना सिखाती है।
verification-before-completion
311kयह आपके एजेंट को किसी काम, सुधार या build के पूरा या पास होने का दावा करने से पहले असली जांच चलाकर उसका आउटपुट पढ़ना सिखाती है।
migrate-to-shoehorn
310kआपकी टेस्ट फ़ाइलों में जोखिम भरे type casts की जगह shoehorn लाइब्रेरी लगाती है, ताकि टेस्ट अधूरे डेटा से भी type checks पास कर सकें।