MSTEST0007: Use test attributes only on test methods
Property | Value |
---|---|
Rule ID | MSTEST0007 |
Title | Use test attributes only on test methods |
Category | Usage |
Fix is breaking or non-breaking | Non-breaking |
Enabled by default | Yes |
Default severity | Info |
Introduced in version | 3.3.0 |
Cause
A method that's not marked with TestMethodAttribute has one or more test attributes applied to it.
Rule description
The following test attributes should only be applied on methods marked with the TestMethodAttribute attribute:
- CssIterationAttribute
- CssProjectStructureAttribute
- DescriptionAttribute
- ExpectedExceptionAttribute
- OwnerAttribute
- PriorityAttribute
- TestPropertyAttribute
- WorkItemAttribute
How to fix violations
To fix a violation of this rule, either convert the method on which you applied the test attributes to a test method by setting the [TestMethod]
attribute or remove the test attributes altogether.
When to suppress warnings
Do not suppress a warning from this rule. If you ignore this rule, your attributes will be ignored since they are designed for use only in a test context.
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