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.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for