简体   繁体   English

如何在一个自动化脚本中涵盖多个测试用例

[英]How to cover multiple test cases in one automation script

In many cases I find it redundant to write a script for each little test case. 在许多情况下,我发现为每个小测试用例编写脚本是多余的。 How can I use Microsoft VS to write a script that can test more than one test case and report the result to each associated test case in Microsoft MTM without running each test cases separately. 如何使用Microsoft VS编写脚本,该脚本可以测试多个测试用例,并将结果报告给Microsoft MTM中的每个相关测试用例,而无需分别运行每个测试用例。 Say, for example, I have a yes/No/Cancel dialog that pops up and there is a test case to verify for each of the three cases. 举例来说,我弹出一个是/否/取消对话框,并且有一个测试用例可以验证这三种情况的每一个。 All three cases can be verified in one script. 可以在一个脚本中验证所有三种情况。 Would it be possible to associate each test case to the same script and get the results reported to each one by running the script only once? 是否可以将每个测试用例与同一脚本关联,并通过只运行一次脚本来将结果报告给每个脚本?

You can use MSTest.exe or VSTest.console.exe to run TestMethods via command line. 您可以使用MSTest.exe或VSTest.console.exe通过命令行运行TestMethods。 One can call MSTest.exe or VSTest.console.exe in batch file. 可以在批处理文件中调用MSTest.exe或VSTest.console.exe。

Assign user defined testcategory attribute to group your tests. 分配用户定义的testcategory属性以对测试进行分组。 Please refer Defining Test Categories to Group Your Tests . 请参阅定义测试类别以对测试进行分组 For Example 例如

[TestCategory("Nightly"),
 TestCategory("Weekly"), 
 TestCategory("ShoppingCart"), 
TestMethod()]
public Void DebitTest()
{
}

[TestCategory("Nightly"),
 TestCategory("Weekly"), 
 TestCategory("ShoppingCart"), 
TestMethod()]
public Void CreditTest()
{
}

[TestCategory("Nightly"),
 TestCategory("Daily"), 
 TestCategory("ShoppingCart"), 
TestMethod()]
public Void BVTTest1()
{
}

[TestCategory("Nightly"),
 TestCategory("Daily"), 
 TestCategory("ShoppingCart"), 
TestMethod()]
public Void BVTTest2()
{
}

Running Tests via VSTest.Console.exe group by TestCategory 通过TestCategory通过VSTest.Console.exe组运行测试

Vstest.console.exe myTestProject.dll /TestCaseFilter:”TestCategory=Nightly"

Running Tests by MSTest.exe group by Test Category 按测试类别按MSTest.exe组运行测试

mstest /testcontainer:MyTestprojectName.dll /category:"Nightly"
mstest /testcontainer:MyTestprojectName.dll /category:"Daily"

Please refer MSDN Link for more command line options in this topic. 请参考MSDN链接以获取本主题中的更多命令行选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将自动化测试执行结果更新到 AzureDevOps/TFS 中的测试用例中 - How to update automation test execution results into the test cases in AzureDevOps/TFS 将多个测试用例链接到一个测试用例 - link multiple test cases to one test case 如何编写测试用例? - How to write Test Cases? 如何为具有多个状态的Singleton对象运行测试用例? - How to run test cases for Singleton object with multiple state? 如何在一种方法上用不同的情况编写断言测试,并且在与不同的响应案例进行比较时,所有这些都通过了? - How to write Assert test with different cases on one method and all of them pass when comparing with different response cases? 如何使用Microsoft Test Manager在多个系统中从TFS自动化多个测试用例? - How to automate multiple test cases from TFS in multiple systems using Microsoft Test Manager? 如何通过仅编写一个单元测试来涵盖各种注入服务的所有异常? - How can I cover all the exceptions from various injected services by writing only one unit test? 如何为工作流创建自动化测试 - How to create an automation test for a workflow 我如何按顺序依次运行Selenium C#测试用例? - How i can run selenium C# test cases in order one by one? 使用一个变量执行NUnit测试用例 - Executing NUnit test cases with one variable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM