MSTest design rules
Design rules will help you create and maintain test suites that adhere to proper design and good practices.
Identifier | Name | Description |
---|---|---|
MSTEST0004 | PublicTypeShouldBeTestClassAnalyzer | It's considered a good practice to have only test classes marked public in a test project. |
MSTEST0006 | AvoidExpectedExceptionAttributeAnalyzer | Prefer Assert.ThrowsException or Assert.ThrowsExceptionAsync over [ExpectedException] as it ensures that only the expected call throws the expected exception. The assert APIs also provide more flexibility and allow you to assert extra properties of the exception. |
MSTEST0015 | TestMethodShouldNotBeIgnored | Test methods should not be ignored (marked with [Ignore] ). |
MSTEST0016 | TestClassShouldHaveTestMethod | Test class should have at least one test method or be 'static' with method(s) marked by '[AssemblyInitialization]' and/or '[AssemblyCleanup]'. |
MSTEST0019 | PreferTestInitializeOverConstructorAnalyzer | Prefer TestInitialize methods over constructors |
MSTEST0020 | PreferConstructorOverTestInitializeAnalyzer | Prefer constructors over TestInitialize methods |
MSTEST0021 | PreferDisposeOverTestCleanupAnalyzer | Prefer Dispose over TestCleanup methods |
MSTEST0022 | PreferTestCleanupOverDisposeAnalyzer | Prefer TestCleanup over Dispose methods |
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