共用方式為


MSTest 設計規則

設計規則可協助您建立和維護符合適當設計和良好作法的測試套件。

Identifier Name Description
MSTEST0004 PublicTypeShouldBeTestClassAnalyzer 最好只在測試專案中將測試類別標示為公用。
MSTEST0006 AvoidExpectedExceptionAttributeAnalyzer 優先選擇 Assert.ThrowsExactlyAssert.ThrowsExactlyAsync,而不是 [ExpectedException],因為這可確保只有預期的呼叫會擲回預期的例外。 斷言 API 也提供更大的彈性,讓您可以斷言例外的額外屬性。
MSTEST0015 TestMethodShouldNotBeIgnored 不應忽略測試方法(以 [Ignore]標示)。
MSTEST0016 TestClassShouldHaveTestMethod 測試類別至少應有一個測試方法,或是類別為 'static' 並具有以 [AssemblyInitialization] 和/或 [AssemblyCleanup]標記的方法。
MSTEST0019 PreferTestInitializeOverConstructorAnalyzer 偏好TestInitialize方法而不是建構函式
MSTEST0020 PreferConstructorOverTestInitializeAnalyzer 偏好建構函式而不是 TestInitialize 方法
MSTEST0021 PreferDisposeOverTestCleanupAnalyzer 建議使用 Dispose 而非 TestCleanup 方法
MSTEST0022 PreferTestCleanupOverDisposeAnalyzer 偏好 TestCleanup 而不是 Dispose 方法
MSTEST0025 PreferAssertFailOverAlwaysFalseConditionsAnalyzer 請使用『Assert.Fail』來取代總是失敗的斷言。
MSTEST0029 PublicMethodShouldBeTestMethod 標記為 public 之類別的 [TestClass] 方法應該是測試方法(以 [TestMethod]標示)。 此規則會忽略以 [TestInitialize][TestCleanup] 屬性標記的方法。
MSTEST0036 DoNotUseShadowingAnalyzer 觀察測試成員可能會導致測試問題(例如 NRE)。
MSTEST0044 PreferTestMethodOverDataTestMethodAnalyzer 方法或類型會使用 DataTestMethodAttribute 或繼承自它。
MSTEST0045 UseCooperativeCancellationForTimeoutAnalyzer 測試方法會使用 TimeoutAttribute ,而不將 CooperativeCancellation 屬性設定為 true