Methods marked with '[AssemblyCleanup]' should follow the following layout to be valid: -it can't be declared on a generic class -it should be 'public' -it should be 'static' -it should not be 'async void' -it should not be a special method (finalizer, operator...). -it should not be generic -it should not take any parameter -return type should be 'void', 'Task' or 'ValueTask' The type declaring these methods should also respect the following rules: -The type should be a class -The class should be 'public' or 'internal' (if the test project is using the '[DiscoverInternals]' attribute) -The class shouldn't be 'static' -The class should be marked with '[TestClass]' (or a derived attribute) -the class should not be generic. 標示為 '[AssemblyCleanup]' 的方法應該遵循下列配置才能有效: -其不能在泛型類別上宣告 - 其應為 'public' - 其應為 'static' - 其不應為 'async void' - 其不應為特殊方法 (完成項、運算子...)。 - 其不應為泛型 - 其不應接受任何參數 - 傳回類型應為 'void'、'Task' 或 'ValueTask' 宣告這些方法的類型還應遵循以下規則: -類型應為類別 -類別應為 'public' 或 'internal' (如果測試專案使用 '[DiscoverInternals]' 屬性) -類別不應為 'static' -類別應標示為 '[TestClass]' (或衍生屬性)。 -類別不應為泛型。 AssemblyCleanup method '{0}' signature is invalid AssemblyCleanup 方法 '{0}' 簽章無效 AssemblyCleanup methods should have valid layout AssemblyCleanup 方法應該具有有效的配置 Methods marked with '[AssemblyInitialize]' should follow the following layout to be valid: -it can't be declared on a generic class -it should be 'public' -it should be 'static' -it should not be 'async void' -it should not be a special method (finalizer, operator...). -it should not be generic -it should take one parameter of type 'TestContext' -return type should be 'void', 'Task' or 'ValueTask' The type declaring these methods should also respect the following rules: -The type should be a class -The class should be 'public' or 'internal' (if the test project is using the '[DiscoverInternals]' attribute) -The class shouldn't be 'static' -The class should be marked with '[TestClass]' (or a derived attribute) -the class should not be generic. 標示為 '[AssemblyInitialize]' 的方法應該遵循下列配置才能有效: -其不能在泛型類別上宣告 - 其應為 'public' - 其應為 'static' - 其不應為 'async void' - 其不應為特殊方法 (完成項、運算子...)。 - 其不應為泛型 - 其應該接受類型為 'TestContext' 的一個參數 - 傳回類型應為 'void'、'Task' 或 'ValueTask' 宣告這些方法的類型還應遵循以下規則: -類型應為類別 -類別應為 'public' 或 'internal' (如果測試專案使用 '[DiscoverInternals]' 屬性) -類別不應為 'static' -類別應標示為 '[TestClass]' (或衍生屬性)。 -類別不應為泛型。 AssemblyInitialize method '{0}' signature is invalid AssemblyInitialize 方法 '{0}' 簽章無效 AssemblyInitialize methods should have valid layout AssemblyInitialize 方法應該具有有效的配置 Prefer adding an additional assertion that checks for null 偏好新增檢查 Null 的其他判斷提示 Avoid conditional access in assertions 避免判斷提示中的條件式存取 'Assert.AreEqual', 'Assert.AreNotEqual', 'Assert.AreSame' and 'Assert.AreNotSame' expects the expected value to be passed first and the actual value to be passed as second argument. 'Assert.AreEqual'、'Assert.AreNotEqual'、'Assert.AreSame' 和 'Assert.AreNotSame' 預期值必須先傳遞,而實際值則會以第二個引數傳遞。 Assertion arguments should be passed in the correct order. 'actual' and 'expected'/'notExpected' arguments have been swapped. 應該以正確的順序傳遞判斷提示引數。已交換 'actual' 和 'expected'/'notExpected' 引數。 Assertion arguments should be passed in the correct order 應該以正確的順序傳遞判斷提示引數 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 exeption. 偏好 'Assert.ThrowsException' or 'Assert.ThrowsExceptionAsync' 而非 '[ExpectedException]',因為它可確保只有預期的呼叫會擲出預期的例外狀況。判斷提示 API 也提供更多彈性,並允許您斷言例外狀況的額外屬性。 Prefer 'Assert.ThrowsException/ThrowsExceptionAsync' over '[ExpectedException]' 偏好 'Assert.ThrowsException/ThrowsExceptionAsync' 而非 '[ExpectedException]' Avoid '[ExpectedException]' 避免 '[ExpectedException]' Methods marked with '[ClassCleanup]' should follow the following layout to be valid: -it can't be declared on a generic class without the 'InheritanceBehavior' mode is set -it should be 'public' -it should be 'static' -it should not be 'async void' -it should not be a special method (finalizer, operator...). -it should not be generic -it should not take any parameter -return type should be 'void', 'Task' or 'ValueTask' -'InheritanceBehavior.BeforeEachDerivedClass' attribute parameter should be specified if the class is 'abstract' -'InheritanceBehavior.BeforeEachDerivedClass' attribute parameter should not be specified if the class is 'sealed' The type declaring these methods should also respect the following rules: -The type should be a class -The class should be 'public' or 'internal' (if the test project is using the '[DiscoverInternals]' attribute) -The class shouldn't be 'static' -If the class is 'sealed', it should be marked with '[TestClass]' (or a derived attribute) -the class should not be generic. 標示 '[ClassCleanup]' 的方法應該遵循下列配置,才會有效: -未設定 'InheritanceBehavior' 模式的情況下不能在泛型類別上宣告它 - 其應為 'public' - 其應為 'static' - 其不應為 'async void' - 其不應為特殊方法 (完成項、運算子...)。 - 其不應為泛型 - 其不應接受任何參數 - 傳回類型應為 'void'、'Task' 或 'ValueTask' - 如果類別為 'abstract',應指定 'InheritanceBehavior.BeforeEachDerivedClass' 屬性參數。 - 如果類別為 'sealed',則不應指定 'InheritanceBehavior.BeforeEachDerivedClass' 屬性參數。 宣告這些方法的類型還應遵循以下規則: -類型應為類別 -類別應為 'public' 或 'internal' (如果測試專案使用 '[DiscoverInternals]' 屬性) -類別不應為 'static' -如果類別是 'sealed',則應標示為 '[TestClass]' (或衍生屬性)。 -類別不應為泛型。 ClassCleanup method '{0}' signature is invalid ClassCleanup 方法 '{0}' 簽章無效 ClassCleanup methods should have valid layout ClassCleanup 方法應該具有有效的配置 Methods marked with '[ClassInitialize]' should follow the following layout to be valid: -it can't be declared on a generic class without the 'InheritanceBehavior' mode is set -it should be 'public' -it should be 'static' -it should not be 'async void' -it should not be a special method (finalizer, operator...). -it should not be generic -it should take one parameter of type 'TestContext' -return type should be 'void', 'Task' or 'ValueTask' -'InheritanceBehavior.BeforeEachDerivedClass' attribute parameter should be specified if the class is 'abstract' -'InheritanceBehavior.BeforeEachDerivedClass' attribute parameter should not be specified if the class is 'sealed' The type declaring these methods should also respect the following rules: -The type should be a class -The class should be 'public' or 'internal' (if the test project is using the '[DiscoverInternals]' attribute) -The class shouldn't be 'static' -If the class is 'sealed', it should be marked with '[TestClass]' (or a derived attribute) -the class should not be generic. 標示 '[ClassInitialize]' 的方法應該遵循下列配置,才會有效: -未設定 'InheritanceBehavior' 模式的情況下不能在泛型類別上宣告它 - 其應為 'public' - 其應為 'static' - 其不應為 'async void' - 其不應為特殊方法 (完成項、運算子...)。 - 其不應為泛型 - 其應該接受類型為 'TestContext' 的一個參數 - 傳回類型應為 'void'、'Task' 或 'ValueTask' - 如果類別為 'abstract',應指定 'InheritanceBehavior.BeforeEachDerivedClass' 屬性參數。 - 如果類別為 'sealed',則不應指定 'InheritanceBehavior.BeforeEachDerivedClass' 屬性參數。 宣告這些方法的類型還應遵循以下規則: -類型應為類別 -類別應為 'public' 或 'internal' (如果測試專案使用 '[DiscoverInternals]' 屬性) -類別不應為 'static' -如果類別是 'sealed',則應標示為 '[TestClass]' (或衍生屬性)。 -類別不應為泛型。 ClassInitialize method '{0}' signature is invalid ClassInitialize 方法 '{0}' 簽章無效 ClassInitialize methods should have valid layout ClassInitialize 方法應該具有有效的配置 DataRow entry should have the following layout to be valid: - should only be set on a test method; - argument count should match method argument count; - argument type should match method argument type. DataRow 項目應具有下列配置為有效: - 應該只在測試方法上設定; - 引數計數應符合方法引數計數; - 引數類型應該符合方法引數類型。 DataRow argument count should match method parameter count (constructor arguments: {0}, method parameters: {1}) DataRow 引數計數應符合建構函式引數 (方法參數計數: {0}、方法參數: {1}) DataRow argument type should match method parameter type. Mismatches occur at indices: {0} DataRow 引數類型應符合方法參數類型。索引發生不符: {0} Found two conflicting types for generic parameter '{0}'. The conflicting types are '{1}' and '{2}'. 發現兩個衝突的泛型參數類型 '{0}'。衝突的類型 '{1}' 且 '{2}'。 The type of the generic parameter '{0}' could not be inferred. 無法推斷泛型參數 '{0}' 的類型。 DataRow should only be set on a test method DataRow 只能在測試方法上設定 DataRow should be valid DataRow 應該有效 Do not negate boolean assertions, instead use the opposite assertion 請勿否定布林值判斷提示,而是使用相反的判斷提示 Do not negate boolean assertions 請勿否定布林值判斷提示 Do not store TestContext in a static member 請勿將 TestContext 儲存在靜態成員中 Do not store TestContext in a static member 請勿將 TestContext 儲存在靜態成員中 Shadowing test members could cause testing issues (such as NRE). 陰影測試成員可能會導致測試問題 (例如 NRE)。 Member '{0}' already exists in the base class 成員 '{0}' 已經存在於基底類別中 Do not use shadowing 不使用陰影 'System.ComponentModel.DescriptionAttribute' has no effect in the context of tests and you likely wanted to use 'Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute' instead. 'System.ComponentModel.DescriptionAttribute' 在測試內容中沒有作用,建議您改用 'Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute'。 Did you mean to be using 'Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute'? 您是指要使用 'Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute' 嗎? 'System.ComponentModel.DescriptionAttribute' has no effect on test methods 'System.ComponentModel.DescriptionAttribute' 對測試方法無影響 'DynamicData' entry should have the following layout to be valid: - should only be set on a test method; - member should be defined on the type specified; - member should be a method if DynamicDataSourceType.Method is specified or a property otherwise. 'DynamicData' 項目應具有下列配置為有效: - 應該只在測試方法上設定; - 應在指定的類型上定義成員; - 如果指定了 DynamicDataSourceType.Method,則成員應為方法,否則應為屬性。 '[DynamicData]' data member '{0}.{1}' signature is invalid '[DynamicData]' 資料成員 '{0}.{1}' 簽章無效 '[DynamicData]' display name method '{0}.{1}' signature is invalid '[DynamicData]' 顯示名稱方法 '{0}.{1}' 簽章無效 '[DynamicData]' member '{0}.{1}' should be a method '[DynamicData]' 成員 '{0}.{1}' 應為方法 '[DynamicData]' member '{0}.{1}' cannot be found 找不到 '[DynamicData]' 成員 '{0}.{1}' '[DynamicData]' referenced member '{0}.{1}' should return 'IEnumerable<object[]>', 'IEnumerable<Tuple>` or 'IEnumerable<ValueTuple>' '[DynamicData]' 參考成員 '{0}.{1}' 應傳回 'IEnumerable<object[]>', 'IEnumerable<Tuple>` or 'IEnumerable<ValueTuple>' '[DynamicData]' should only be set on a test method [DynamicData]' 只能在測試方法上設定 '[DynamicData]' member '{0}.{1}' is a method so you should use 'DynamicDataSourceType.AutoDetect' or 'DynamicDataSourceType.Method' (auto detect is the default when not specified explicitly, and is recommended) '[DynamicData]' member '{0}.{1}' is a method so you should use 'DynamicDataSourceType.AutoDetect' or 'DynamicDataSourceType.Method' (auto detect is the default when not specified explicitly, and is recommended) '[DynamicData]' member '{0}.{1}' is not a property nor a method. Only properties and methods are supported. '[DynamicData]' member '{0}.{1}' is not a property nor a method. Only properties and methods are supported. '[DynamicData]' member '{0}.{1}' is a property so you should use 'DynamicDataSourceType.AutoDetect' or 'DynamicDataSourceType.Property' (auto detect is the default when not specified explicitly, and is recommended) '[DynamicData]' member '{0}.{1}' is a property so you should use 'DynamicDataSourceType.AutoDetect' or 'DynamicDataSourceType.Property' (auto detect is the default when not specified explicitly, and is recommended) '[DynamicData]' member '{0}.{1}' is found more than once 多次發現 '[DynamicDta]' 成員 '{0}.{1}' DynamicData should be valid DynamicData 應該有效 Use 'Assert.Fail' instead of an always-failing 'Assert.{0}' assert 使用 'Assert.Fail',而不是一直失敗的 'Assert.{0}' 聲明 Use 'Assert.Fail' instead of an always-failing assert 使用 'Assert.Fail',而不是一直失敗的聲明 Review or remove the assertion as its condition is known to be always true 檢閱或移除判斷提示,因為已知其條件一律為 True Assertion condition is always true 判斷提示條件一律為 True Prefer constructors over TestInitialize methods 偏好建構函式勝於 TestInitialize 方法 Prefer constructors over TestInitialize methods 偏好建構函式勝於 TestInitialize 方法 Prefer 'Dispose' over TestCleanup methods 偏好 'Dispose' 勝於 TestCleanup 方法 Prefer 'Dispose' over TestCleanup methods 偏好 'Dispose' 勝於 TestCleanup 方法 Prefer TestCleanup over 'Dispose' methods 偏好 TestCleanup 勝於 'Dispose' 方法 Prefer TestCleanup over 'Dispose' methods 偏好 TestCleanup 勝於 'Dispose' 方法 Prefer TestInitialize methods over constructors 偏好 TestInitialize 方法勝於建構函式 Prefer TestInitialize methods over constructors 偏好 TestInitialize 方法勝於建構函式 Public methods should be test methods (marked with `[TestMethod]`). Public methods should be test methods (marked with `[TestMethod]`). Public method '{0}' should be a test method Public method '{0}' should be a test method Public methods should be test methods Public methods should be test methods It's considered a good practice to have only test classes marked public in a test project. 在測試專案中僅將測試類別標記為公開被認為是一種很好的做法。 Public type '{0}' should be marked with '[TestClass]' or changed to 'internal' 公用類型 '{0}' 應標示為 '[TestClass]' 或變更為 'internal' Public types should be test classes 公用類型應為測試類別 Test class '{0}' should be valid 測試類別 '{0}' 應為有效 Property 'TestContext' should be valid 屬性 'TestContext' 應為有效 Test method '{0}' signature is invalid 測試方法 '{0}' 簽章無效 Without using 'ClassCleanupBehavior.EndOfClass', the '[ClassCleanup]' will by default be run at the end of the assembly and not at the end of the class. 如不使用 'ClassCleanupBehavior.EndOfClass',則預設會在組件結尾執行 '[ClassCleanup]',而非在類別的結尾執行。 Use 'ClassCleanupBehavior.EndOfClass' with the '[ClassCleanup]' 搭配使用 'ClassCleanupBehavior.EndOfClass' 和 '[ClassCleanup]' Use 'ClassCleanupBehavior.EndOfClass' with the '[ClassCleanup]' 搭配使用 'ClassCleanupBehavior.EndOfClass' 和 '[ClassCleanup]' Test classes, classes marked with the '[TestClass]' attribute, should respect the following layout to be considered valid by MSTest: - it should be 'public' (or 'internal' if '[assembly: DiscoverInternals]' attribute is set) - it should not be 'static' (except if it contains only 'AssemblyInitialize' and/or 'AssemblyCleanup' methods) - it should not be generic. 測試類別 (標示為 '[TestClass]' 屬性的類別) 應該遵循下列配置,讓 MSTest 視為有效: - 它應該是 'public' (如果設定 '[assembly: DiscoverInternals]' 屬性,則為 'internal') - 它不應該是 'static' (除非其僅包含 'AssemblyInitialize' 和/或 'AssemblyCleanup' 方法) - 它不能是泛型。 Test classes should have valid layout 測試類別應具備有效的配置 Test class should have at least one test method or be 'static' with method(s) marked by '[AssemblyInitialize]' and/or '[AssemblyCleanup]'. 測試類別至少應有一個測試方法或是 'static',而其方法是以 '[AssemblyInitialization]' 和/或 '[AssemblyCleanup]'標示。 Test class '{0}' should have at least one test method or be 'static' with method(s) marked by '[AssemblyInitialize]' and/or '[AssemblyCleanup]' 測試類別 '{0}' 至少應有一個測試方法或是 'static',而其方法是以 '[AssemblyInitialization]' 和/或 '[AssemblyCleanup]'標示。 Test class should have test method 測試類別應該要有測試方法 Methods marked with '[TestCleanup]' should follow the following layout to be valid: -it should be 'public' -it should not be 'abstract' -it should not be 'async void' -it should not be 'static' -it should not be a special method (finalizer, operator...). -it should not be generic -it should not take any parameter -return type should be 'void', 'Task' or 'ValueTask' The type declaring these methods should also respect the following rules: -The type should be a class -The class should be 'public' or 'internal' (if the test project is using the '[DiscoverInternals]' attribute) -The class shouldn't be 'static' -If the class is 'sealed', it should be marked with '[TestClass]' (or a derived attribute). 標示為 '[TestCleanup]' 的方法應該遵循下列配置才能有效: - 其應為 'public' - 其不應為 'abstract' - 其不應為 'async void' - 其不應為 'static' - 其不應為特殊方法 (完成項、運算子...)。 - 其不應為泛型 - 其不應接受任何參數 - 傳回類型應為 'void'、'Task' 或 'ValueTask' 宣告這些方法的類型還應遵循以下規則: -類型應為類別 -類別應為 'public' 或 'internal' (如果測試專案使用 '[DiscoverInternals]' 屬性) -類別不應為 'static' -如果類別是 'sealed',則應標示為 '[TestClass]' (或衍生屬性)。 TestCleanup method '{0}' signature is invalid TestCleanup 方法 '{0}' 簽章無效 TestCleanup method should have valid layout TestCleanup 方法應具有有效的配置 'TestContext' should be a non-static field or property assigned in constructor or for a property set by MSTest, it should follow the layout: - it should be 'public' regardless of whether '[assembly: DiscoverInternals]' attribute is set or not. - it should not be 'static' - it should have a setter. 'TestContext' 應是在建構函式中指派的非靜態欄位或屬性,或是針對由 MSTest 所設定的屬性,其應遵循下列配置: - 它應該是 'public' (無論是否有設定 '[assembly: DiscoverInternals]' 屬性)。 - 它不應該是 'static' - 它應該有 setter。 Test context property should have valid layout 測試內容屬性應該具有有效的配置 Methods marked with '[TestInitialize]' should follow the following layout to be valid: -it should be 'public' -it should not be 'abstract' -it should not be 'async void' -it should not be 'static' -it should not be a special method (finalizer, operator...). -it should not be generic -it should not take any parameter -return type should be 'void', 'Task' or 'ValueTask' The type declaring these methods should also respect the following rules: -The type should be a class -The class should be 'public' or 'internal' (if the test project is using the '[DiscoverInternals]' attribute) -The class shouldn't be 'static' -If the class is 'sealed', it should be marked with '[TestClass]' (or a derived attribute). 標示為 '[TestInitialize]' 的方法應該遵循下列配置才能有效: - 其應為 'public' - 其不應為 'abstract' - 其不應為 'async void' - 其不應為 'static' - 其不應為特殊方法 (完成項、運算子...)。 - 其不應為泛型 - 其不應接受任何參數 - 傳回類型應為 'void'、'Task' 或 'ValueTask' 宣告這些方法的類型還應遵循以下規則: -類型應為類別 -類別應為 'public' 或 'internal' (如果測試專案使用 '[DiscoverInternals]' 屬性) -類別不應為 'static' -如果類別是 'sealed',則應標示為 '[TestClass]' (或衍生屬性)。 TestInitialize method '{0}' signature is invalid TestInitialize 方法 '{0}' 簽章無效 TestInitialize method should have valid layout TestInitialize 方法應具備有效的配置 Test methods, methods marked with the '[TestMethod]' attribute, should respect the following layout to be considered valid by MSTest: - it should be 'public' (or 'internal' if '[assembly: DiscoverInternals]' attribute is set) - it should not be 'static' - it should may be generic as long as type parameters can be inferred and argument types are compatible - it should not be 'abstract' - return type should be 'void', 'Task' or 'ValueTask' - it should not be 'async void' - it should not be a special method (finalizer, operator...). 測試方法 (標示為 '[TestMethod]' 屬性的方法) 應該遵循下列配置,讓 MSTest 視為有效: - 它應該是 'public' (如果設定 '[assembly: DiscoverInternals]' 屬性,則為 'internal') - 它應該是 'static' - 只要可以推斷類型參數且引數類型相容,則其應為一般 - 它不能是 'abstract' - 傳回型別應為 'void'、'Task' 或 'ValueTask' - 它不能是 'async void' - 它不應該是特殊方法 (完成項、運算子...)。 Test methods should have valid layout 測試方法應具備有效的配置 Test methods should not be ignored (marked with '[Ignore]'). 不應略過測試方法 (標示為 '[Ignore]')。 Test method '{0}' should not be ignored 不應略過測試方法 '{0}' Test method should not be ignored 不應略過測試方法 Type contaning '[TestMethod]' should be marked with '[TestClass]', otherwise the test method will be silently ignored. 包含 '[TestMethod]' 的類型應標記為 '[TestClass]',否則將以無訊息的方式忽略測試方法。 Class '{0}' contains test methods and should be marked with '[TestClass]' 類別 '{0}' 包含測試方法,應以 '[TestClass]' 標記 Type containing '[TestMethod]' should be marked with '[TestClass]' 包含 '[TestMethod]' 的類型應標記為 '[TestClass]' Asynchronous test fixture methods do not require the 'Async' suffix 非同步測試固件方法不需要 'Async' 尾碼 Asynchronous test methods do not require the 'Async' suffix 非同步測試方法不需要 'Async' 尾碼 [{0}] can only be set on methods marked with [TestMethod] [{0}] 只能在標示為 [TestMethod] 的方法上設定 [{0}] can only be set on methods marked with [TestMethod] [{0}] 只能在標示為 [TestMethod] 的方法上設定 '[DeploymentItem]' can be specified only on test class or test method '[DeploymentItem]' 只能在測試類或測試方法上指定 '[DeploymentItem]' can be specified only on test class or test method '[DeploymentItem]' 只能在測試類或測試方法上指定 By default, MSTest runs tests within the same assembly sequentially, which can lead to severe performance limitations. It is recommended to enable assembly attribute '[Parallelize]' to run tests in parallel, or if the assembly is known to not be parallelizable, to use explicitly the assembly level attribute '[DoNotParallelize]'. 根據預設,MSTest 會依順序執行在相同組件內的測試,這可能會導致嚴重的效能限制。建議啟用組件屬性 '[Parallelize]' 來平行執行測試,或者如果已知組件無法平行處理,則明確使用組件層級的屬性 '[DoNotParallelize]'。 Explicitly enable or disable tests parallelization 明確啟用或停用測試平行處理 Explicitly enable or disable tests parallelization 明確啟用或停用測試平行處理 Use 'Assert.{0}' instead of 'Assert.{1}' 使用 'Assert.{0}' 取代 'Assert.{1}' Use proper 'Assert' methods 使用適當的 'Assert' 方法