是否可以通过Microsoft Test Manager中的SpecFlow标记选择测试用例?如果是这样,怎么样?
答案 0 :(得分:2)
SpecFlow中的标记在生成的代码中被转换为TestCategory属性。据我所知(直到一年前与MTM合作)你可以:
使用最后一个选项,您可以创建一组具有按测试类别排序的不同测试的测试计划。而且我担心如果不在MTM上编写自己的包装器,这是最好的。 TestCategory信息在TFS中可用,但不在MTM中向用户公开。
修改强>
在评论后澄清事项 鉴于此功能文件:
@timtim
Feature: MSTest Tags Test
In order to get feedback at the right time
As a test automation specialist
I want to categorize my tests and run them accordingly
@Jabberwocky @manxome
Scenario: A test with tags
Given 'twas brillig
When gyre and gimble in the wabe
Then all mimsy were the borogoves
它生成此代码:
[Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
[Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("A test with tags")]
[Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "MSTest Tags Test")]
[Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("timtim")]
[Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Jabberwocky")]
[Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("manxome")]
public virtual void ATestWithTags()
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("A test with tags", new string[] {
"Jabberwocky",
"manxome"});
#line 8
this.ScenarioSetup(scenarioInfo);
#line 9
testRunner.Given("\'twas brillig", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 10
testRunner.When("gyre and gimble in the wabe", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 11
testRunner.Then("all mimsy were the borogoves", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
this.ScenarioCleanup();
}
该方案成为(通过MSTest.exe)可执行测试方法,其中包含三个TestCategories:timtim
,Jabberwocky
和manxome
。这些是与文章中提到的相同的测试类别。 Coded UI does have a Test Category property可用于订购测试,但此类别可归结为使用the same TestCategory
attribute。