Skip to content

QA-CS-102 — Hard sleep in test ​

← Back to the rule catalog

Generated from the rule registry. Get the same detail from the CLI with mjolnir explain QA-CS-102.

FieldValue
Severitywarning
Confidencehigh
Tierextended
Measured FP rate8% (n=24)
Evidence levelE2
QA impactFlaky-test risk (FLAKY-RISK)
False-positive risk (author estimate)low
Autofix availableno
Languagescsharp
Frameworksnunit, xunit, mstest, playwright
Detection strategyAST (L2 tree-sitter invocation scoping (route/expose/server delegates, infinite blocks, WhenAny races, runner payload fixtures); regex fallback when no parse)
Introduced inv0.3.8

Why this fails in production ​

Fixed sleeps are flaky under load and slow everywhere; Playwright locators auto-wait for actionability.

What gets flagged (real detector output) ​

`Thread.Sleep(` used to wait for state.

Example from this rule's own must-fire fixture: tests/fixtures/QA-CS-102/must-fire/DashboardTests.cs

The fix ​

Use await Assertions.Expect(locator).ToBeVisibleAsync() or locator.WaitForAsync().

Confirmed NOT to fire on the corresponding clean pattern ​

Verified against tests/fixtures/QA-CS-102/must-not-fire/DashboardTests.cs — a legitimate, similar-looking pattern this rule correctly leaves alone.

Corpus-measured false-positive risk ​

Real occurrence counts from npm run corpus:audit against actively-maintained OSS repos — reproduce yourself, don't just trust this table (see the false-positive audit):

RepoOccurrences
microsoft-playwright-dotnet21
positive-fixtures4
SeleniumHQ-selenium3

Released under the MIT License.