MSTEST0003: Test methods should have valid layout
Property | Value |
---|---|
Rule ID | MSTEST0003 |
Title | Test methods should have valid layout |
Category | Usage |
Fix is breaking or non-breaking | Breaking |
Enabled by default | Yes |
Default severity | Warning |
Introduced in version | 3.2.0 |
Cause
A test method is not following single or multiple points of the required test method layout.
Rule description
Test methods (methods marked with the [TestMethod]
attribute) should follow the given layout to be considered valid by MSTest:
- they should be
public
(orinternal
if[assembly: DiscoverInternals]
attribute is set) - they should not be
static
- they should not be generic
- they should not be
abstract
- they should return
void
orTask
- they should not be
async void
- they should not be a special method (constructor, finalizer, operator...)
How to fix violations
Ensure that the test method matches the required layout described above.
When to suppress warnings
Do not suppress a warning from this rule. Ignoring this rule will result in tests being ignored, because MSTest will not consider this method to be a test method.
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.
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