Select Microsoft 测试管理器中按 SpecFlow 标记的测试用例
Select test cases by SpecFlow tag in Microsoft Test Manager
是否可以在 Microsoft 测试管理器中通过 SpecFlow 标记 select 测试用例?如果是,怎么做?
SpecFlow 中的标签在生成的代码中被翻译成 TestCategory 属性。据我所知(直到一年前才使用 MTM)你可以:
- Execute tests with MSTest filtered on TestCategory by Categories
- Execute tests with VSTest.Console filtered on TestCategory by TestCaseFilter
- Import test cases into MTM filtered on TestCategory
使用最后一个选项,您可以通过一些创意创建一组测试计划,其中包含按测试类别排序的不同测试。恐怕这是您在不围绕 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 that can be used to order the tests, but this category boiles down to using the same TestCategory
attribute.
是否可以在 Microsoft 测试管理器中通过 SpecFlow 标记 select 测试用例?如果是,怎么做?
SpecFlow 中的标签在生成的代码中被翻译成 TestCategory 属性。据我所知(直到一年前才使用 MTM)你可以:
- Execute tests with MSTest filtered on TestCategory by Categories
- Execute tests with VSTest.Console filtered on TestCategory by TestCaseFilter
- Import test cases into MTM filtered on TestCategory
使用最后一个选项,您可以通过一些创意创建一组测试计划,其中包含按测试类别排序的不同测试。恐怕这是您在不围绕 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 that can be used to order the tests, but this category boiles down to using the same TestCategory
attribute.