【发布时间】:2015-08-28 16:24:05
【问题描述】:
是否可以在 Microsoft 测试管理器中通过 SpecFlow 标签选择测试用例?如果有,怎么做?
【问题讨论】:
标签: specflow microsoft-test-manager mtm
是否可以在 Microsoft 测试管理器中通过 SpecFlow 标签选择测试用例?如果有,怎么做?
【问题讨论】:
标签: specflow microsoft-test-manager mtm
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。
【讨论】:
@Acceptance。例如,@Acceptance Given ... When ... Then ... (see other examples)。 TestCategory 似乎是 CodedUI 测试之上的一种特殊属性,而不是场景标签。所以不幸的是,你的建议在这里似乎不起作用。如果我有更多时间,我会尝试找到一种方法,您的建议确实对 tcm 工具的功能提供了一些启发。
.feature.cs 文件,您可以看到您自己的标签如何成为测试类别。