MSTEST0024: Do not store TestContext in a static member
Property | Value |
---|---|
Rule ID | MSTEST0024 |
Title | Do not store TestContext in a static member |
Category | Usage |
Fix is breaking or non-breaking | Non-breaking |
Enabled by default | Yes |
Default severity | Info |
Introduced in version | 3.4.0 |
Cause
This rule raises a diagnostic when an assignment to a static
member of a TestContext
parameter is done.
Rule description
The TestContext
parameter passed to each initialize method ([AssemblyInitialize]
or [ClassInitialize]
) is specific to the current context and is not updated on each test execution. Storing, for reuse, this TextContext
object will most of the time lead to issues.
How to fix violations
Do not store the [AssemblyInitialize]
or [ClassInitialize]
TestContext
parameter.
When to suppress warnings
You can suppress warnings from this rule if you are sure of the behavior does match what you want to do.
Feedback
https://aka.ms/ContentUserFeedback.
Kommer snart: I hele 2024 udfaser vi GitHub-problemer som feedbackmekanisme for indhold og erstatter det med et nyt feedbacksystem. Du kan få flere oplysninger under:Indsend og få vist feedback om