Skip to main content

Practice ยท 2 of 2

Diagnose the flaky test

Implement diagnose_flaky(test_record) โ€” the record has booleans uses_time, uses_random_unseeded, shared_state, order_dependent: - returns (verdict, causes): 'flaky' when any cause fires, else 'sound' - causes are human-readable fixes in fixed order: time โ†’ 'reads the wall clock: inject a clock'; randomness โ†’ 'unseeded randomness: seed it'; shared state โ†’ 'shared state: give each test its own world'; order dependence โ†’ 'order-dependent: construct prerequisites in the test' Mechanized triage: the reviewer's first five minutes, as a function.

Difficulty: advanced

Back to lesson: Practice: Property & Diagnosis Drills