How to teach SpecFlow to add additional NUnit attributes to my test class

拜拜、爱过 提交于 2019-12-03 13:38:31

In fact the NUnit.Framework.Category attribute is already supported if you use tags (look for the tags section) on your feature or scenarios. So if you write

@LongRunningTests
Feature: MySampleFeature

it will generate the proper Category attribute.

However if you want to have additional custom attributes you need to write a custom generator provider with implementing the IUnitTestGeneratorProvider interface and register with the unitTestProvider's generatorProvider attribute in your config's specflow section.

You can find the source of the built in implementations at github.

To add to @nemesv's good answer, once you've added:

@LongRunningTests Feature: MySampleFeature

To execute from the console, do this:

nunit3-console.exe myTests.dll --where "cat==LongRunningTests"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!