.NET 的黄瓜替代品

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/976078/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 12:50:23  来源:igfitidea点击:

Cucumber alternative for .NET

.netcucumber

提问by Owen

Quick one, has anyone come across a library similar to Ruby's cucumber (a human readable DSL for defining use case stories that can be tested against) in the .NET sphere?

很快,有没有人在 .NET 领域遇到过类似于 Ruby 的黄瓜(一种人类可读的 DSL,用于定义可以测试的用例故事)的库?

回答by Gaspar Nagy

You should also check out SpecFlow, that is an open-source project to do BDD with .NET.

您还应该查看SpecFlow,这是一个使用 .NET 进行 BDD 的开源项目。

SpecFlow is using the same definition format (Gherkin), like cucumber, but you can write your step definitions in .NET. It basically generates unit-test classes (NUnit, MsTest, xUnit, etc.) from your feature files, so you can use the same unit test execution engine, like you do with the real unit tests. This way it is also easier to integrate the BDD functional tests to the integration build.

SpecFlow 使用与黄瓜相同的定义格式 (Gherkin),但您可以在 .NET 中编写步骤定义。它基本上从您的功能文件中生成单元测试类(NUnit、MsTest、xUnit 等),因此您可以使用相同的单元测试执行引擎,就像使用真正的单元测试一样。通过这种方式,还可以更轻松地将 BDD 功能测试集成到集成构建中。

In the recent versions SpecFlow has a syntax coloring feature for Visual Studio 2010 and support for Silverlight and Mono/MonoDevelop.

在最近的版本中,SpecFlow 具有 Visual Studio 2010 的语法着色功能并支持 Silverlight 和 Mono/MonoDevelop。

回答by J?rg W Mittag

Sure. It's called Cucumber. There's an example for how to test .NET code in the Cucumber examples directoryand documentation on the Cucumber Wiki for both .NETand Mono.

当然。它叫黄瓜。在Cucumber 示例目录和 Cucumber Wiki 上的.NETMono文档中,有一个关于如何测试 .NET 代码的示例

回答by Kevin Berridge

There seem to be 3 possibilities in this space:

这个空间似乎有 3 种可能性:

  1. Use Cucumber and IronRuby. Here's a blogon some steps to get started with this. The downside seems to be performance. I've read accounts that say its slower in general, and others that say it's just really slow to spin up. This is far from conclusive though, since IronRuby is still in active development.

  2. Use Cuke4Nuke. I've heard this product recommended a few times. It actually uses regular Ruby and Cucumber but runs your .NET code through a server. Fortunately, all that complication is transparent as you are using it. Cuke4Nuke is no longer under active development.

  3. Use SpecFlow. This is a .NET port of Cucumber. Because of this, it may not have all of Cucumber's features, and it may have extra features. The nice thing is you don't have to have Ruby installed.

  1. 使用 Cucumber 和 IronRuby。 这是有关开始使用此操作的一些步骤的博客。缺点似乎是性能。我读过一些帐户说它总体上比较慢,而其他人说它只是旋转起来很慢。不过这还远没有定论,因为 IronRuby 仍在积极开发中。

  2. 使用Cuke4Nuke。我听说这个产品推荐了几次。它实际上使用常规的 Ruby 和 Cucumber,但通过服务器运行您的 .NET 代码。幸运的是,当您使用它时,所有这些复杂性都是透明的。Cuke4Nuke 不再处于积极开发阶段。

  3. 使用SpecFlow。这是 Cucumber 的 .NET 端口。因此,它可能不具备 Cucumber 的所有功能,并且可能具有额外的功能。好消息是您不必安装 Ruby。

At this time it doesn't seem clear which of these is the best option. Personally I'm planning on starting with Cuke4Nuke.

目前还不清楚哪些是最好的选择。我个人计划从 Cuke4Nuke 开始。

回答by Johan Bergens

StoryTeller is somewhat related even though it is not strictly BDD. It seems to support a somewhat different kind of test but is written in .NET. Read more on Jeremy Millers blog

尽管 StoryTeller 并非严格意义上的 BDD,但它还是有些相关的。它似乎支持某种不同类型的测试,但它是用 .NET 编写的。在Jeremy Millers 博客上阅读更多内容

回答by Will Green

I wrote up a blog post detailing the process I followed to get Cucumber running with IronRuby: http://hotgazpacho.org/2009/06/cucumber-and-ironruby-it-runs/

我写了一篇博客文章,详细介绍了我使用 IronRuby 运行 Cucumber 所遵循的过程:http: //hotgazpacho.org/2009/06/cucumber-and-ironruby-it-runs/

回答by user3632158

BDD in plain Englishcan be done with Concordion.NET. The specifications of the expected behavior are written in HTML.

可以使用Concordion.NET完成简单英语的 BDD。预期行为的规范是用 HTML 编写的。

Any sentences of any structure can be used for Concordion.NET tests. For example it is not necessary to write a sentence such as "given a bank account with a balance of 10$, when a withdrawal of 20$ is initiated, the transaction fails". Instead any type of sentence could be used such as "a transaction of 20$ fails, if the account contains not enough balance of 10$".

任何结构的任何句子都可以用于 Concordion.NET 测试。比如“给定一个银行账户余额为10$,发起提款20$,交易失败”这样的句子就没有必要了。相反,可以使用任何类型的句子,例如“如果账户余额不足 10 美元,则 20 美元的交易失败”。

Concordion.NET tests are executed with the help of NUnit, which is integrated in many different environments: https://github.com/concordion/concordion-net

Concordion.NET 测试在 NUnit 的帮助下执行,NUnit 集成在许多不同的环境中:https: //github.com/concordion/concordion-net

回答by todd

There is also StoryQ. This is a dev focussed approach to user stories that can report back out clients. http://storyq.codeplex.com

还有StoryQ。这是一种以开发人员为中心的用户故事方法,可以报告客户。 http://storyq.codeplex.com

StoryQ is a portable (single dll), embedded BDD framework for .NET 3.5. It runs within your existing test runner and helps produce human-friendly test output (html or text). StoryQ's fluent interface adds strong typing, intellisense and documentation to your BDD grammar.

StoryQ 是用于 .NET 3.5 的可移植(单个 dll)、嵌入式 BDD 框架。它在您现有的测试运行器中运行,并有助于生成人性化的测试输出(html 或文本)。StoryQ 流畅的界面为您的 BDD 语法添加了强类型、智能感知和文档。

回答by rupakg

I have an article showing how to use Cucumber with C# at http://blog.webintellix.com/2009/10/how-to-use-cucumber-with-net-and-c.htmlThe run times have improved dramatically with IronRuby 1.0.

我有一个展示如何使用黄瓜用C#的文章http://blog.webintellix.com/2009/10/how-to-use-cucumber-with-net-and-c.html的运行时间有显着改善铁红宝石 1.0。