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 |
There is a code fix | Yes |
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.
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.