![](/img/trans.png)
[英]How do I tell mstest to ignore tests in a base class but not in subclasses?
[英]MSTest Parameterization of Tests - how do I name the test case?
我希望能夠命名我的測試用例。 我怎么做?
[TestClass]
public class RegressionTests
{
[DataRow(SendProposalRequest.systemError, false, 110, SystemValidations.SystemErrorText)]
[DataRow(SendProposalRequest.proposalError, false, 22, SystemValidations.PTErrorText)]
[DataRow(SendProposalRequest.financeError, false, 22, SystemValidations.FTErrorText)]
[DataRow(SendProposalRequest.noFinance, false, 53, SystemValidations.noFinanceErrorText)]
[DataRow(SendProposalRequest.annualMileage, false, 22, SystemValidations.annualMileageErrorText)]
[DataRow(SendProposalRequest.loanAmountBoth, false, 33, SystemValidations.loanAmountBothErrorText)]
[DataRow(SendProposalRequest.proposalError, false, 22, SystemValidations.PTErrorText)]
[DataTestMethod]
public void ValidationTests(string requestType, bool valid, int errorCode, string errorText)
{
TestSetup.TestSetupMethod(requestType, valid, errorCode, errorText);
}
我不清楚您的問題是關於命名測試方法還是更改測試名稱,因為它出現在 Visual Studio 測試資源管理器中。 我將假設您要更改測試資源管理器中的測試名稱,或運行測試時生成的測試結果文件。
DataRowAttribute class 有一個名為“ DisplayName ”的屬性,您可以使用它來自定義該測試變體的名稱:
[TestClass]
public class RegressionTests
{
[DataTestMethod]
[DataRow(SendProposalRequest.systemError, false, 110, SystemValidations.SystemErrorText, DisplayName = "System error")]
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
public void ValidationTests(string requestType, bool valid, int errorCode, string errorText)
使用它的基本格式是:
[DataRow(arg1, arg2, ... argN, DisplayName = "Your custom name here")]
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.