如何让 VS2010 识别 SpecFlow 生成的 mstest?

2023-12-29

我已将 Specflow 配置为以 MsTest 框架(而不是 NUnit)为目标,方法是在“specs”类库的 app.config 中指定它:

<configSections>
    <section name="specFlow"
   type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
</configSections>

<specFlow>
 <unitTestProvider name="MsTest.2010" />
</specFlow>

因此,一旦就位,我可以看到 Specflow 自定义工具正确生成了我的测试装置,并具有正确的 TestClass Attribute() 和方法等:

[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.3.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute()]
...

规范类已构建,但现在我无法在 vista 64 机器上使用 Visual Studio 2010 内的测试 --> 运行 --> 解决方案中的所有测试来运行测试。为什么 VS 不将这些识别为要运行的有效测试?


As per 德罗助手 http://blog.drorhelper.com/2008/12/how-to-convert-net-class-library-to-ms.html and 亚历克斯·杜格尔比 http://alexduggleby.com/2008/02/19/turning-a-class-library-project-into-a-mstest-project-or-using-mbunit-mstest-and-other-frameworks-in-one-project/您需要将以下行添加到 .csproj 文件中:

<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

将其添加到 FileAlignment 元素之后,然后重新加载项目。它现在应该是一个 MS Test 项目,并且您可以在此项目的上下文中获得 MS Test 功能。指南的意思是:

  • {3AC096D0-A1C2-E12C-1390-A8335801FDAB} - 测试项目
  • {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - C# 类库
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何让 VS2010 识别 SpecFlow 生成的 mstest? 的相关文章

随机推荐