简体   繁体   English

如果没有JRuby / gem,是否可以在Java中运行Cucumber?

[英]Is is possible to run Cucumber in Java out of the box without JRuby/gems?

I am new to Cucumber, JRuby, Gems and how it works. 我是Cucumber,JRuby,Gems的新手以及它是如何工作的。

I like the idea of writing down the test case in plain English, but I am not keen on installing a lot of new tools (I really really like Java), just to get Cucumber up and running. 我喜欢用简单的英文写下测试用例的想法,但我并不热衷于安装很多新工具(我真的非常喜欢Java),只是为了让Cucumber正常运行。

So I have a few questions. 所以我有几个问题。

1) Do I need install JRuby/Ruby to use Cucumber in Java? 1)我是否需要安装JRuby / Ruby才能在Java中使用Cucumber? No way to avoid this? 没办法避免这个?

2) If not, are there alternative test-tools, that is similar to Cucumber, that works in Java out of the box? 2)如果没有,是否有替代测试工具,类似于Cucumber,开箱即用的Java工作?

What alternatives do I have to minimize new tools just to get Cucumber/similar-tool working? 为了让Cucumber /类似工具正常工作,我还有哪些方法可以最小化新工具?

Cucumber-JVM正是您所需要的。

A mature pure Java alternative to Cucumber is JBehave JBehave是Cucumber的成熟纯Java替代品

Also Aslak Hellesoy (the creator of Cucumber) promised a native Java version of Cucumber to be released somewhen in 2011 (see his CukeUp keynote ) 此外,Aslak Hellesoy(Cucumber的创建者)承诺将在2011年发布一些原生Java版本的Cucumber(参见他的CukeUp主题演讲

I compared Cucumber, Cucumber-JVM and JBehave. 我比较了Cucumber,Cucumber-JVM和JBehave。 They are all meant for writing acceptance tests that are based on either features (Cucumber, Cucumber-JVM) or stories. 它们都用于编写基于功能(Cucumber,Cucumber-JVM)或故事的验收测试。

Cucumber's main disadvantages are that it's brittle when used via the Cuke4Duke Maven plugin in a pure Java environment since it requires maintaining its underlying Ruby (gem) infrastructure. Cucumber的主要缺点是,在纯Java环境中通过Cuke4Duke Maven插件使用它时会很脆弱,因为它需要维护其底层的Ruby(gem)基础设施。 It's also comparably slow and direct debugging isn't possible - you will need to attach a remote debugger instead. 它也相对较慢并且无法直接调试 - 您需要连接远程调试器。

JBehave is a very mature, pure Java alternative to Cucumber. JBehave是Cucumber非常成熟,纯粹的Java替代品。 It's output isn't quite as pretty as Cucumber's, but it's well documented, easy to use, and fast. 它的输出并不像Cucumber那么漂亮,但它有很好的记录,易于使用和快速。 There is native support for JUnit. 有对JUnit的本机支持。

As of December 2011, you can now additionally use a pure Java version of Cucumber which is called Cucumber-JVM. 截至2011年12月,您现在可以另外使用名为Cucumber-JVM的纯Java版Cucumber。 It is just as fast and easy to use as JBehave, and it has native JUnit support. 它与JBehave一样快速和易用,并且具有原生JUnit支持。 Unfortunately, it doesn't have any pretty HTML-based result output, not even the rudimentary offerings of JBehave, though this should be fixed in the coming months. 不幸的是,它没有任何漂亮的基于HTML的结果输出,甚至没有JBehave的基本产品,尽管这应该在未来几个月内修复。 It also lacks documentation. 它也缺乏文件。 Its main advantage over JBehave is the support of features instead of stories. 它相对于JBehave的主要优势是支持功能而不是故事。

If you like the idea of writing tests in plain english, then Twist is your best bet. 如果你喜欢用简单的英语写测试的想法,那么Twist是你最好的选择。 Underlying test code will be in java. 底层测试代码将在java中。

Check out cuke4duke . 看看cuke4duke It's cucumber for the JVM, no Ruby required. 它是JVM的黄瓜,不需要Ruby。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM