![](/img/trans.png)
[英]How to update automation test execution results into the test cases in AzureDevOps/TFS
[英]How to cover multiple test cases in one automation script
在许多情况下,我发现为每个小测试用例编写脚本是多余的。 如何使用Microsoft VS编写脚本,该脚本可以测试多个测试用例,并将结果报告给Microsoft MTM中的每个相关测试用例,而无需分别运行每个测试用例。 举例来说,我弹出一个是/否/取消对话框,并且有一个测试用例可以验证这三种情况的每一个。 可以在一个脚本中验证所有三种情况。 是否可以将每个测试用例与同一脚本关联,并通过只运行一次脚本来将结果报告给每个脚本?
您可以使用MSTest.exe或VSTest.console.exe通过命令行运行TestMethods。 可以在批处理文件中调用MSTest.exe或VSTest.console.exe。
分配用户定义的testcategory属性以对测试进行分组。 请参阅定义测试类别以对测试进行分组 。 例如
[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()
{
}
通过TestCategory通过VSTest.Console.exe组运行测试
Vstest.console.exe myTestProject.dll /TestCaseFilter:”TestCategory=Nightly"
按测试类别按MSTest.exe组运行测试
mstest /testcontainer:MyTestprojectName.dll /category:"Nightly"
mstest /testcontainer:MyTestprojectName.dll /category:"Daily"
请参考MSDN链接以获取本主题中的更多命令行选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.