黄瓜 vs 朱尼特

Cucumber vs Junit(黄瓜 vs 朱尼特)

本文介绍了黄瓜 vs 朱尼特的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下 Cucumber 和 JUnit 之间的实际区别是什么.我根本没有和 Cucumber 合作过.找到了一些文档,但我非常感谢曾与这两者合作过的人的一些反馈(对高 lvl 概述感兴趣).

I'd like to ask what's the practical difference between Cucumber and JUnit. I haven't worked with Cucumber at all; found some documentation but I'd greatly appreciate some feedback from someone who has worked with both (interested in a high lvl overview).

分解一下——我感兴趣的是什么(我将使用 Selenium 而不是 Protractor):

To break it down - what i'm interested in (I'll be using Selenium and not Protractor) :

  1. Cucumber 与 Junit 有什么不能做的事.
  2. 什么更容易使用(编码,编写测试的速度)?
  3. 两者都适用于页面对象?

我需要完成的一些事情

  1. 测试 CSS 样式
  2. 测试页面响应能力
  3. WebElements 上的标准操作(点击、获取数据等)
  4. 断言.

除此之外的任何内容都非常受欢迎.非常感谢您对此的回答,谢谢!

Anything in addition to this is more than welcomed. Greatly appreciate your answer on this, thank you!

推荐答案

JUnit 和 Cucumber 的目标不同.它们相互补充而不是相互替代.

JUnit and Cucumber are aiming at different goals. They are rather complement to each other than replace each other.

Cucumber 和 Junit 有什么不能做的事.

Are there any things that Cucumber can't do vs Junit.

您可以用 JUnit 做任何您不能用 Cucumber 做的事情.反之亦然.

There isn't anything you can do with JUnit that you can't do with Cucumber. And the other way around.

不同之处在于,JUnit 的目标是测试,而 Cucumber 的目标是与非技术人员协作.非技术人员不会理解单元测试的作用.但是,他们将能够理解并验证用 Gherkin 编写的示例.

The difference is that while JUnit aims at tests, Cucumber aims at collaboration with non technical people. Non technical people will not understand what a unit test does. They will, however, be able to understand and validate an example written in Gherkin.

什么更容易使用(编码,编写测试的速度)?

What's easier to use (coding, how fast you can write the tests) ?

使用 Cucumber 会产生更多开销.您必须将每个步骤作为一种方法来实现,而不仅仅是一个测试方法,就像使用 JUnit 时所做的那样.使用纯文本表达示例所获得的可读性有时值得付出额外的努力.

There is more overhead when you use Cucumber. You will have to implement each step as a method and not just one test method as you would do if you used JUnit. The readability you gain from expressing examples using plain text is sometimes worth the extra work.

两者都适用于页面对象?

Both work with Page Objects?

页面对象是您正在验证的网页的抽象.这是您作为开发人员/测试人员编写的课程.JUnit 和 Cucumber 都可以使用页面对象.事实上,从这个角度来看,工具之间没有区别.

Page Objects are an abstraction for the web page you are verifying. It is a class you write as developer/tester. The Page Objects can be used by both JUnit and Cucumber. In fact, there is no difference between the tools from that perspective.

选择使用 JUnit 还是 Cucumber 是粒度和受众的问题.

The choice to use JUnit or Cucumber is a matter of granularity and audience.

一个运作良好的工作流程是混合工具.定义应用程序应如何使用 BDD(Cucumber、Gherkin)工作的示例.使用 Cucumber 实现这些场景.然后,使用 JUnit 制定对高层业务利益相关者可能重要但不必要的细节.考虑一些重要但对利益相关者来说细节过多的极端案例.

A work flow that works well is to mix the tools. Define examples of how the application should work using BDD, (Cucumber, Gherkin). Implement these scenarios using Cucumber. Then, use JUnit to work out details that may be important but not necessary important for the business stakeholders at a high level. Think of corner cases that are important but are too much details for your stakeholders.

此处提供了描述这种组合的图片:https://cucumber.io/图片/home/bdd-cycle.png

An image that describes this mix is available here: https://cucumber.io/images/home/bdd-cycle.png

我不久前写了一篇博文,谈到了适合这项工作的工具:http://www.thinkcode.se/blog/2016/07/25/the-right-tool-for-the-job

I wrote blog post a while back where I talk about the right tool for the job: http://www.thinkcode.se/blog/2016/07/25/the-right-tool-for-the-job

正确的工具可能是 Cucumber.它也可以是 JUnit.这完全取决于您的观众.

The right tool may be Cucumber. It can also be JUnit. It all depends on your audience.

这篇关于黄瓜 vs 朱尼特的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:黄瓜 vs 朱尼特

基础教程推荐