नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
| Property | Value |
|---|---|
| Rule ID | MSTEST0048 |
| Title | Avoid TestContext properties in fixture methods |
| Category | Usage |
| Fix is breaking or non-breaking | Non-breaking |
| Enabled by default | Yes |
| Default severity | Warning |
| Introduced in version | 3.10.0 |
| Is there a code fix | No |
Cause
A fixture method (methods with AssemblyInitializeAttribute, AssemblyCleanupAttribute, ClassInitializeAttribute, or ClassCleanupAttribute) accesses restricted TestContext properties.
Rule description
Certain TestContext properties aren't available in fixture methods because they're specific to individual test execution:
Properties unavailable in class and assembly fixture methods:
TestDataTestDisplayNameDataRowDataConnectionTestNameManagedMethod
Properties unavailable in assembly-level fixture methods:
FullyQualifiedTestClassNameManagedType
How to fix violations
Remove the usage of restricted TestContext properties from fixture methods. Consider using alternative approaches for class/assembly initialization and cleanup that don't rely on test-specific context information.
When to suppress warnings
Don't suppress warnings from this rule. Accessing these properties in fixture methods can result in unexpected behavior or runtime errors.