SpecFlow自动生成StepDefinition文件,有可能吗?

时间:2011-06-08 20:09:45

标签: c# nunit specflow

我目前正在使用C#进行编程,我正在使用Visual Studio 2010,.Net 4,SpecFlow,NUnit,我很好奇,如果有一种方法可以让SpecFlow自动为我生成一个* StepDefintion.cs *。功能文件。目前,我必须将生成的代码复制并粘贴到新的“SpecFlow步骤定义”文件中。

如果有人知道这是否可能,以及如何做到这一点会很棒!

2 个答案:

答案 0 :(得分:3)

最新版本的SpecFlow在IDE集成中具有此功能..

Select “Generate Step Definitions” from the context menu of the feature file and the appearing dialog will guide you how to create a new binding class with the step definitions for the selected unbound steps. You don’t have to care about parameters: the most common parameter usage patterns (quotes, apostrophes, numbers) are detected. You can also choose from different step definition styles, including the new regex-less formats (see below).

enter image description here

http://www.specflow.org/specflownew/WhatsNew19.html

答案 1 :(得分:2)

没有开箱即用。有一个关于使用nUnit并在步骤中将代码粗略化的教程,但是我没有在项目中使用SpecFlow足够长的时间来确定它生成此存根代码的位置。一点搜索应该找到答案。最糟糕的情况是,使用nUnit中生成的代码找到SpecFlow和nUnit的教程(非常简洁的东西,虽然不是自动化的)。

我有一些代码,我开始编写以创建存根文件,但不使用SpecFlow的决定让我远离这个方向(不能再证明时间了)。我以为我在博客上写了一篇文章,但搜索我的博客产生了nada(ASIDE:你可以在网站上找到SpecFlow:gregorybeamer.wordpress.com,但这是一个普通的“单元测试”帖子)。

我曾考虑过为代码做贡献,但考虑到我现在没有空闲时间来为开源做贡献,不同可能性的数量让我大开眼界。 ; - )

相关问题