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.ThrowsExactly or Assert.ThrowsExactlyAsync 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 |
MSTEST0025 | PreferAssertFailOverAlwaysFalseConditionsAnalyzer | Use 'Assert.Fail' instead of an always-failing assert |
MSTEST0029 | PublicMethodShouldBeTestMethod | A public method of a class marked with [TestClass] should be a test method (marked with [TestMethod] ). The rule ignores methods that are marked with [TestInitialize] , or [TestCleanup] attributes. |
MSTEST0036 | DoNotUseShadowingAnalyzer | Shadowing test members could cause testing issues (such as NRE). |
Συνεργαστείτε μαζί μας στο GitHub
Μπορείτε να βρείτε την πηγή για αυτό το περιεχόμενο στο GitHub, όπου μπορείτε επίσης να δημιουργήσετε και να εξετάσετε ζητήματα και αιτήματα έλξης. Για περισσότερες πληροφορίες, ανατρέξτε στον οδηγό συνεργατών.