[英]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.