Skip to content

Detect Thread.Sleep(x) and Thread.Wait(x) inside test code to reduce flakiness #6950

Description

@stan-sz

Detect Thread.Sleep(x) and Thread.Wait(x) inside test code to reduce flakiness

Background and Motivation

Thread.Sleep(x) and Thread.Wait(x) are causing test flakiness when operation is not completed in the specific time frame. In most of the cases asynchronous calls would be much better solution.

Proposed Feature

Detection of Thread.Sleep(x) and Thread.Wait(x) should be added for the test code so INFO or WARNING should inform developer during build time that there is possible flakiness in the test code.

Alternative Designs

Currently we are detecting above patterns using CodeQL inside the test code. Using test analyzer would be much better solution because it would shift the detection to the left (build time), speeding up detection and increasing quality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/analyzers

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions