黄瓜vs Junit [英] Cucumber vs Junit

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

问题描述

我想问一下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).

要分解一下-我要做什么? m感兴趣(我将使用Selenium而不是Protractor):

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


  1. 在黄瓜和Junit之间有什么不能做的事情。

  2. 更容易使用的是什么(编码,编写测试的速度如何)?

  3. 都可以使用Page对象吗?

我需要完成的某些事情


  1. 测试CSS样式

  2. 测试页面的响应能力

  3. WebElement的标准操作(单击,获取数据等)

  4. 声明。

  1. Test css styling
  2. Test page responsiveness
  3. Standard operation on WebElements (clicking, getting data etc)
  4. Asserts.

除此以外的任何内容都值得欢迎。

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.


还有黄瓜不能比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.


是否都可以使用Page Objects?

Both work with Page Objects?

页面对象是您要验证的网页的抽象。这是您作为开发人员/测试人员编写的类。 JUnit和Cucumber都可以使用Page对象。实际上,从这种角度来看,工具之间没有区别。

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/images/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

正确的工具可能是黄瓜。也可以是JUnit。这完全取决于您的听众。

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

这篇关于黄瓜vs Junit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆