mar*_*c_s 7 nunit class-attributes specflow
SpecFlow非常棒 - 它非常有助于我们进行适当的集成测试.
我想知道的一件事是,是否有办法告诉SpecFlow将其他NUnit属性添加到它在功能代码隐藏文件中创建的测试类中.
现在,我的测试类生成如下:
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.8.1.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Some action description here")]
public partial class MySampleFeature
{
......
}
Run Code Online (Sandbox Code Playgroud)
在SpecFlow中是否有任何方法告诉它添加额外的NUnit属性来定义测试的类别 - 如下所示:
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.8.1.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Some action description here")]
[NUnit.Framework.Category("LongRunningTests")] <== add this "Category" attribute
public partial class MySampleFeature
{
......
}
Run Code Online (Sandbox Code Playgroud)
手动将其添加到生成的代码隐藏是浪费 - 下次SpecFlow重新生成代码隐藏时,我必须记住再次执行它(很可能,我会忘记).
如果SpecFlow中还没有这种能力 - 如何申请加入?:-)
nem*_*esv 10
实际上,NUnit.Framework.Category
如果您在功能或方案上使用标记(查找标记部分),则已支持该属性.所以,如果你写
@LongRunningTests
Feature: MySampleFeature
Run Code Online (Sandbox Code Playgroud)
它会生成适当的Category
属性.
但是,如果您想拥有其他自定义属性,则需要编写自定义生成器提供程序,并实现该IUnitTestGeneratorProvider
接口并在config的specflow部分中注册unitTestProvider的generatorProvider
属性.
您可以在github上找到内置实现的源代码.
归档时间: |
|
查看次数: |
6064 次 |
最近记录: |